Flawfinder version 2.0.10, (C) 2001-2019 David A. Wheeler. Number of rules (primarily dangerous function names) in C/C++ ruleset: 223 Examining data/snmptrapfmt-1.17/log.c Examining data/snmptrapfmt-1.17/log.h Examining data/snmptrapfmt-1.17/snmptrapfmt.c Examining data/snmptrapfmt-1.17/snmptrapfmt.h Examining data/snmptrapfmt-1.17/snmptrapfmthdlr.c FINAL RESULTS: data/snmptrapfmt-1.17/log.c:104:3: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf (fp_log, fmt, ap); data/snmptrapfmt-1.17/snmptrapfmt.c:810:9: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(lbuf, "%s", hent->h_name); data/snmptrapfmt-1.17/snmptrapfmt.c:815:9: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(lbuf, "%s", name); data/snmptrapfmt-1.17/snmptrapfmt.c:836:9: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(lbuf, "%s", inet_ntoa(in)); data/snmptrapfmt-1.17/snmptrapfmt.c:840:9: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(lbuf, "%s", name); data/snmptrapfmt-1.17/snmptrapfmt.c:878:7: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(lbuf, "%s", oidP ? oidP : "(null)"); data/snmptrapfmt-1.17/snmptrapfmt.c:882:7: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(lbuf, "%s", oidP ? oidP : "(null)"); data/snmptrapfmt-1.17/snmptrapfmt.c:945:3: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(lbuf, iFmt, ival); data/snmptrapfmt-1.17/snmptrapfmt.c:978:3: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(lbuf, uFmt, uval); data/snmptrapfmt-1.17/snmptrapfmt.c:1474:3: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(trapoid, trapoidP); data/snmptrapfmt-1.17/snmptrapfmt.c:1508:11: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(buf, p_delim + 1); data/snmptrapfmt-1.17/snmptrapfmt.c:1524:9: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(buf, p_delim + 1); data/snmptrapfmt-1.17/snmptrapfmt.c:1540:7: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(buf, trapoid); data/snmptrapfmt-1.17/snmptrapfmt.c:1561:3: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(trapoid, trapoidP); data/snmptrapfmt-1.17/snmptrapfmt.c:1579:9: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(buf, p_delim + 1); data/snmptrapfmt-1.17/snmptrapfmt.c:269:9: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. c = getopt_long(argc, argv, "Dd:f:", long_options, &option_index); data/snmptrapfmt-1.17/log.c:64:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char tbuf[24]; data/snmptrapfmt-1.17/log.c:78:13: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fp_fd = open (fp_fname, O_CREAT|O_EXCL|O_WRONLY, S_IREAD|S_IWRITE); data/snmptrapfmt-1.17/snmptrapfmt.c:211:18: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). if ((pidfile = open(PIDFILE, O_WRONLY | O_CREAT, 0644)) != -1) data/snmptrapfmt-1.17/snmptrapfmt.c:216:7: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char pid[11]; data/snmptrapfmt-1.17/snmptrapfmt.c:222:7: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(pid, "%d", getpid()); data/snmptrapfmt-1.17/snmptrapfmt.c:276:20: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). o_loglev = atoi(optarg); data/snmptrapfmt-1.17/snmptrapfmt.c:343:13: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fd_pipe = open(PIPENAME, O_RDWR, S_IWUSR | S_IRUSR); data/snmptrapfmt-1.17/snmptrapfmt.c:435:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char lbuf[1024]; data/snmptrapfmt-1.17/snmptrapfmt.c:441:15: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). if (!(cfg = fopen(cfgname, "r"))) data/snmptrapfmt-1.17/snmptrapfmt.c:622:13: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). f_log = fopen(cfg_logname, "a"); data/snmptrapfmt-1.17/snmptrapfmt.c:641:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char *oidfmt[2]; data/snmptrapfmt-1.17/snmptrapfmt.c:642:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char *nodefmt[3]; data/snmptrapfmt-1.17/snmptrapfmt.c:669:10: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. static char buf[4000]; /* the output buffer */ data/snmptrapfmt-1.17/snmptrapfmt.c:798:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char lbuf[80]; /* local buffer for result */ data/snmptrapfmt-1.17/snmptrapfmt.c:870:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char lbuf[1024]; /* local buffer */ data/snmptrapfmt-1.17/snmptrapfmt.c:939:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char lbuf[20]; /* local buffer */ data/snmptrapfmt-1.17/snmptrapfmt.c:972:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char lbuf[20]; /* local buffer */ data/snmptrapfmt-1.17/snmptrapfmt.c:1351:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char rbuf[1024]; data/snmptrapfmt-1.17/snmptrapfmt.c:1469:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char trapoid[2048]; data/snmptrapfmt-1.17/snmptrapfmt.c:1470:10: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. static char buf[80]; data/snmptrapfmt-1.17/snmptrapfmt.c:1492:9: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf, "%d", SNMP_TRAP_ENTERPRISESPECIFIC); data/snmptrapfmt-1.17/snmptrapfmt.c:1504:11: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf, "%d", gid - 1); data/snmptrapfmt-1.17/snmptrapfmt.c:1520:9: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf, "%d", gid - 1); data/snmptrapfmt-1.17/snmptrapfmt.c:1536:7: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf, "%d", gid - 1); data/snmptrapfmt-1.17/snmptrapfmt.c:1556:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char trapoid[2048]; data/snmptrapfmt-1.17/snmptrapfmt.c:1557:10: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. static char buf[80]; data/snmptrapfmt-1.17/snmptrapfmthdlr.c:56:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char inbuf[8192]; /* the read buffer */ data/snmptrapfmt-1.17/snmptrapfmthdlr.c:65:16: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). o_loglev = atoi (argv[2]); data/snmptrapfmt-1.17/snmptrapfmthdlr.c:77:8: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fd = open (PIPENAME, O_WRONLY | O_NONBLOCK); data/snmptrapfmt-1.17/snmptrapfmt.c:223:27: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). write(pidfile, pid, strlen(pid)); data/snmptrapfmt-1.17/snmptrapfmt.c:846:7: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). l = strlen(lbuf); data/snmptrapfmt-1.17/snmptrapfmt.c:849:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(*cPPtr, lbuf, l); data/snmptrapfmt-1.17/snmptrapfmt.c:887:7: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). l = strlen(lbuf); data/snmptrapfmt-1.17/snmptrapfmt.c:890:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(*cPPtr, lbuf, l); data/snmptrapfmt-1.17/snmptrapfmt.c:915:7: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). l = strlen(stringP); data/snmptrapfmt-1.17/snmptrapfmt.c:918:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(*cPPtr, stringP, l); data/snmptrapfmt-1.17/snmptrapfmt.c:948:7: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). l = strlen(lbuf); data/snmptrapfmt-1.17/snmptrapfmt.c:951:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(*cPPtr, lbuf, l); data/snmptrapfmt-1.17/snmptrapfmt.c:981:7: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). l = strlen(lbuf); data/snmptrapfmt-1.17/snmptrapfmt.c:984:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(*cPPtr, lbuf, l); data/snmptrapfmt-1.17/snmptrapfmt.c:1053:7: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). l = strlen(p); data/snmptrapfmt-1.17/snmptrapfmt.c:1056:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(*cPPtr, p, l); data/snmptrapfmt-1.17/snmptrapfmt.c:1133:35: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int l = strlen(var->v_val); data/snmptrapfmt-1.17/snmptrapfmt.c:1369:9: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). l = strlen(rbuf); data/snmptrapfmt-1.17/snmptrapfmt.c:1411:23: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int l = strlen(buf); data/snmptrapfmt-1.17/snmptrapfmt.c:1584:9: [1] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). Risk is low because the source is a constant character. strcpy(buf, "0"); data/snmptrapfmt-1.17/snmptrapfmt.c:1590:7: [1] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). Risk is low because the source is a constant character. strcpy(buf, "0"); data/snmptrapfmt-1.17/snmptrapfmt.c:1596:5: [1] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). Risk is low because the source is a constant character. strcpy(buf, "0"); data/snmptrapfmt-1.17/snmptrapfmthdlr.c:88:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((rcnt = read (0, inbuf, sizeof (inbuf))) > 0) ANALYSIS SUMMARY: Hits = 65 Lines analyzed = 1893 in approximately 0.08 seconds (23660 lines/second) Physical Source Lines of Code (SLOC) = 1330 Hits@level = [0] 16 [1] 20 [2] 29 [3] 1 [4] 15 [5] 0 Hits@level+ = [0+] 81 [1+] 65 [2+] 45 [3+] 16 [4+] 15 [5+] 0 Hits/KSLOC@level+ = [0+] 60.9023 [1+] 48.8722 [2+] 33.8346 [3+] 12.0301 [4+] 11.2782 [5+] 0 Minimum risk level = 1 Not every hit is necessarily a security vulnerability. There may be other security vulnerabilities; review your code! See 'Secure Programming HOWTO' (https://dwheeler.com/secure-programs) for more information.