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/lx-gdb-1.03/gdbdump.c Examining data/lx-gdb-1.03/gdbload.c FINAL RESULTS: data/lx-gdb-1.03/gdbload.c:177:4: [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(szNew, pszDatabase); data/lx-gdb-1.03/gdbload.c:178:4: [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(szOld, pszDatabase); data/lx-gdb-1.03/gdbload.c:190:4: [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(szNew, pszDatabase); data/lx-gdb-1.03/gdbload.c:191:4: [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(szOld, pszDatabase); data/lx-gdb-1.03/gdbload.c:200: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(szNew, pszDatabase); data/lx-gdb-1.03/gdbload.c:201: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(szOld, pszDatabase); data/lx-gdb-1.03/gdbload.c:379: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(szCategories+1, (char *)record); data/lx-gdb-1.03/gdbload.c:765:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(buf, ";%s;", line); /* Copy to buffer */ data/lx-gdb-1.03/gdbload.c:774:6: [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(szCategories, buf); data/lx-gdb-1.03/gdbload.c:776:6: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(szCategories, buf+1); data/lx-gdb-1.03/gdbload.c:819:4: [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((char *)record+*endrec, (char *)line); data/lx-gdb-1.03/gdbdump.c:173:8: [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 charbuf[2] = { 0, 0 }; data/lx-gdb-1.03/gdbdump.c:174:8: [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 intbuf[5] = { '\\', 0, 0, 0, 0 }; data/lx-gdb-1.03/gdbdump.c:197:5: [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(intbuf, "\\%03o", *s); data/lx-gdb-1.03/gdbdump.c:305:2: [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 buf[20]; /* date/time formatting buffer */ data/lx-gdb-1.03/gdbdump.c:341:4: [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, "%02d%02d", word / 60, word % 60); data/lx-gdb-1.03/gdbdump.c:349:4: [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, "%04d%02d%02d", rec[offset]+1900, data/lx-gdb-1.03/gdbdump.c:474: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). if (!(hf = fopen(*argv, "rb")) && data/lx-gdb-1.03/gdbdump.c:475: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). !(hf = fopen(*argv, "r"))) /* Open the database file */ data/lx-gdb-1.03/gdbload.c:104:1: [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 szNew[BUFSIZ]; /* Database.NEW */ data/lx-gdb-1.03/gdbload.c:105:1: [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 szOld[BUFSIZ]; /* Database.BAK */ data/lx-gdb-1.03/gdbload.c:106:1: [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 szCategories[257]; /* Categories in database */ data/lx-gdb-1.03/gdbload.c:179:4: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. strcat(szNew, ".new"); data/lx-gdb-1.03/gdbload.c:180:4: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. strcat(szOld, ".bak"); data/lx-gdb-1.03/gdbload.c:192:4: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. strcat(szNew, ".new"); data/lx-gdb-1.03/gdbload.c:193:4: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. strcat(szOld, ".bak"); data/lx-gdb-1.03/gdbload.c:202:3: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. strcat(szNew, ".new"); data/lx-gdb-1.03/gdbload.c:203:3: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. strcat(szOld, ".bak"); data/lx-gdb-1.03/gdbload.c:394:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(fields[cFields], record, reclen); data/lx-gdb-1.03/gdbload.c:459:16: [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 (!(hfOld = fopen(pszDatabase, "rb")) && data/lx-gdb-1.03/gdbload.c:460:16: [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). !(hfOld = fopen(pszDatabase, "r"))) data/lx-gdb-1.03/gdbload.c:462:16: [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 (!(hfNew = fopen(szNew, "wb")) && data/lx-gdb-1.03/gdbload.c:463:16: [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). !(hfNew = fopen(szNew, "w"))) data/lx-gdb-1.03/gdbload.c:511:3: [2] (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 string. strcpy(szCategories, ";;"); data/lx-gdb-1.03/gdbload.c:651:2: [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 namebuf1[21], data/lx-gdb-1.03/gdbload.c:681:16: [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 (!(hfIn = fopen(pszInput, "rt")) && data/lx-gdb-1.03/gdbload.c:682:16: [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). !(hfIn = fopen(pszInput, "r"))) data/lx-gdb-1.03/gdbload.c:755:8: [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[256]; /* Buffer for category name */ data/lx-gdb-1.03/gdbload.c:845:15: [2] (integer) atol: 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). long date = atol((char *)line); data/lx-gdb-1.03/gdbload.c:878:14: [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). int time = atoi((char *)line); data/lx-gdb-1.03/gdbdump.c:139:19: [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). while (cChars + strlen(s) > LINELEN) data/lx-gdb-1.03/gdbdump.c:148:14: [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). cChars += strlen(s); data/lx-gdb-1.03/gdbdump.c:154:13: [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). cChars += strlen(s); data/lx-gdb-1.03/gdbload.c:380:3: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. strcat(szCategories, ";"); data/lx-gdb-1.03/gdbload.c:530:15: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((ch = fgetc(hfIn)) == '\r' || ch == '\n') data/lx-gdb-1.03/gdbload.c:535:16: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((ch = fgetc(hfIn)) != '\n' && !feof(hfIn)) data/lx-gdb-1.03/gdbload.c:571:9: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ch = fgetc(hfIn); data/lx-gdb-1.03/gdbload.c:575:5: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). fgetc(hfIn); data/lx-gdb-1.03/gdbload.c:591:10: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ch = fgetc(hfIn) - '0'; data/lx-gdb-1.03/gdbload.c:592:11: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ch2 = fgetc(hfIn) - '0'; data/lx-gdb-1.03/gdbload.c:610:15: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). chstr_1 = fgetc(hfIn); data/lx-gdb-1.03/gdbload.c:611:15: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). chstr_2 = fgetc(hfIn); data/lx-gdb-1.03/gdbload.c:624:4: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). fgetc(hfIn); data/lx-gdb-1.03/gdbload.c:641:8: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ch = fgetc(hfIn); data/lx-gdb-1.03/gdbload.c:656:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(namebuf1, (char *)name1, 20); data/lx-gdb-1.03/gdbload.c:657:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(namebuf2, (char *)name2, 20); data/lx-gdb-1.03/gdbload.c:662: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). memmove(pch, pch+1, strlen(pch)); data/lx-gdb-1.03/gdbload.c:664: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). memmove(pch, pch+1, strlen(pch)); data/lx-gdb-1.03/gdbload.c:729:17: [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 reclen = strlen((char *)line); data/lx-gdb-1.03/gdbload.c:768:29: [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). if (strlen(szCategories) + strlen(buf) - 2 > 256) { data/lx-gdb-1.03/gdbload.c:768:52: [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). if (strlen(szCategories) + strlen(buf) - 2 > 256) { data/lx-gdb-1.03/gdbload.c:820:15: [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). *endrec += strlen((char *)line) + 1; data/lx-gdb-1.03/gdbload.c:992:11: [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). reclen = strlen(szCategories) - 2 /* extra semicolons */ data/lx-gdb-1.03/gdbload.c:1001: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). fwrite(szCategories + 1, strlen (szCategories) - 2, 1, hfNew); ANALYSIS SUMMARY: Hits = 64 Lines analyzed = 1523 in approximately 0.06 seconds (27539 lines/second) Physical Source Lines of Code (SLOC) = 1060 Hits@level = [0] 26 [1] 24 [2] 29 [3] 0 [4] 11 [5] 0 Hits@level+ = [0+] 90 [1+] 64 [2+] 40 [3+] 11 [4+] 11 [5+] 0 Hits/KSLOC@level+ = [0+] 84.9057 [1+] 60.3774 [2+] 37.7358 [3+] 10.3774 [4+] 10.3774 [5+] 0 Dot directories skipped = 1 (--followdotdir overrides) 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.