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/gfpoken-1/logic.c Examining data/gfpoken-1/multi.c Examining data/gfpoken-1/gfp.h Examining data/gfpoken-1/initial.h Examining data/gfpoken-1/convert.c Examining data/gfpoken-1/interface.c Examining data/gfpoken-1/main.c Examining data/gfpoken-1/dialog.c Examining data/gfpoken-1/common.h Examining data/gfpoken-1/graphics.h Examining data/gfpoken-1/history.c FINAL RESULTS: data/gfpoken-1/multi.c:311:5: [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(transdata, tempstr); data/gfpoken-1/multi.c:339:3: [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(netin, newin); data/gfpoken-1/multi.c:473:3: [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(netin, newin); data/gfpoken-1/multi.c:485:7: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(newin, "V %s\n", GFPNetVer); data/gfpoken-1/multi.c:490:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(newin, "Client: Server running an incompatible version, %s", netin+2); data/gfpoken-1/multi.c:607:3: [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(netin, newin); data/gfpoken-1/multi.c:613:7: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(newin, "Server: Incompatible client version %s",netin+2); data/gfpoken-1/multi.c:615:7: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(newin, "N %s\n", GFPNetVer); data/gfpoken-1/multi.c:674:2: [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(newin, netin); data/gfpoken-1/dialog.c:86:15: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. randpop += (random() % (int)(randpop*densityfuzz*2/100 + 1)) - (int)(randpop*densityfuzz/100); data/gfpoken-1/dialog.c:90:16: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. randland = random() % randinc; data/gfpoken-1/dialog.c:95:15: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. randchoice = random() % sum; data/gfpoken-1/dialog.c:103:19: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. tempobj = (random() % 2)+ObSULDRMirror; data/gfpoken-1/dialog.c:106:19: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. tempobj = (random() % 6)+ObFULDR_URDLMirror; data/gfpoken-1/dialog.c:109:19: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. tempobj = (random() % 2)+ObBBox; data/gfpoken-1/dialog.c:112:19: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. tempobj = (random() % 4)+ObAVertMirror; data/gfpoken-1/dialog.c:115:19: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. tempobj = (random() % 4)+ObRClock; data/gfpoken-1/dialog.c:118:19: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. tempobj = (random() % 4)+ObOTULDRMirror; data/gfpoken-1/dialog.c:121:19: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. tempobj = (random() % 10)+ObEOFCTULDRMirror; data/gfpoken-1/dialog.c:364:21: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. strncpy(configloc,getenv("HOME"),65); data/gfpoken-1/dialog.c:408:19: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. strncpy(readbuf,getenv("HOME"),65); data/gfpoken-1/main.c:929:3: [3] (random) srandom: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srandom(time(NULL)); data/gfpoken-1/dialog.c:175:19: [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 ((savefile = fopen(filename,"w"))) { data/gfpoken-1/dialog.c:204: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 readbuf[80]; data/gfpoken-1/dialog.c:205: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 header[80]; data/gfpoken-1/dialog.c:208:3: [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(header, "GFPSave %d\n", GFPSaveVer); data/gfpoken-1/dialog.c:209:19: [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 ((savefile = fopen(filename,"r"))) { data/gfpoken-1/dialog.c:354: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 configloc[80]; /* Good Enough */ data/gfpoken-1/dialog.c:365: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(configloc,"/.gfpoken"); data/gfpoken-1/dialog.c:366:21: [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 ((configfile = fopen(configloc,"w"))) { data/gfpoken-1/dialog.c:406: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 readbuf[80]; data/gfpoken-1/dialog.c:409: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(readbuf,"/.gfpoken"); data/gfpoken-1/dialog.c:410:21: [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 ((configfile = fopen(readbuf,"r"))) { data/gfpoken-1/main.c:318:3: [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(tmpgrid, grid, gridx*gridy*sizeof(obj)); data/gfpoken-1/main.c:319:3: [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(tmpinvisigrid, invisigrid, gridx*gridy*sizeof(obj)); data/gfpoken-1/multi.c:60: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 netin[Linelen] = ""; data/gfpoken-1/multi.c:275: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 transdata[80] = " "; /* Plenty o' room */ data/gfpoken-1/multi.c:276: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 tempstr[10]; data/gfpoken-1/multi.c:279:3: [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(transdata,"%c", type); data/gfpoken-1/multi.c:310: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(tempstr, " %d",argpiece); data/gfpoken-1/multi.c:327: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 newin[Linelen] = ""; data/gfpoken-1/multi.c:352:19: [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. if (completed) strcpy(newin, "Finish up - "); data/gfpoken-1/multi.c:353:9: [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. else strcpy(newin, "Make a move - "); data/gfpoken-1/multi.c:354:22: [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. if (opponentdone) strcat(newin, "Opponent is done"); data/gfpoken-1/multi.c:355:9: [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. else strcat(newin, "Opponent is not done"); data/gfpoken-1/multi.c:461: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 newin[Linelen] = ""; data/gfpoken-1/multi.c:584: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(newin, "Client: Downloading board, %d%% complete", (100*blockspot)/(gridx*gridy)); data/gfpoken-1/multi.c:597: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 newin[Linelen] = ""; data/gfpoken-1/multi.c:673:2: [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(netin, " %d", invisigrid[blockspot]); data/gfpoken-1/multi.c:680: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(newin, "Server: Uploading board, %d%% complete", (100*blockspot)/(gridx*gridy)); data/gfpoken-1/multi.c:738:33: [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). remoteaddr.sin_port = htons(atoi(port)); data/gfpoken-1/multi.c:761:32: [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). localaddr.sin_port = htons(atoi(port)); data/gfpoken-1/dialog.c:364:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(configloc,getenv("HOME"),65); data/gfpoken-1/dialog.c:408:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(readbuf,getenv("HOME"),65); data/gfpoken-1/multi.c:313: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(transdata, "\n"); data/gfpoken-1/multi.c:314:32: [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(remotesock, transdata, strlen(transdata)); data/gfpoken-1/multi.c:331:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). switch (read(remotesock, newin, SSIZE_MAX > Linelen-1 ? Linelen-1 : SSIZE_MAX)) { data/gfpoken-1/multi.c:340: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). if (netin[strlen(netin)-1] != '\n') return TRUE; data/gfpoken-1/multi.c:465:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). switch ((tmp = read(remotesock, newin, SSIZE_MAX > Linelen-1 ? Linelen-1 : SSIZE_MAX))) { data/gfpoken-1/multi.c:474: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). if (netin[strlen(netin)-1] != '\n') return TRUE; data/gfpoken-1/multi.c:486:32: [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(remotesock, newin, strlen(newin)); data/gfpoken-1/multi.c:491: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). newin[strlen(newin)-2] = '\0'; /* Get rid of offending \n */ data/gfpoken-1/multi.c:599:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). switch (read(remotesock, newin, SSIZE_MAX > Linelen-1 ? Linelen-1 : SSIZE_MAX)) { data/gfpoken-1/multi.c:608: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). if (netin[strlen(netin)-1] != '\n') return TRUE; data/gfpoken-1/multi.c:611: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). netin[strlen(netin)-1] = '\0'; data/gfpoken-1/multi.c:616:32: [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(remotesock, newin, strlen(newin)); data/gfpoken-1/multi.c:671:7: [1] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source is a constant character. sprintf(newin, "B"); data/gfpoken-1/multi.c:677:7: [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(newin,"\n"); data/gfpoken-1/multi.c:679:32: [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(remotesock, newin, strlen(newin)); ANALYSIS SUMMARY: Hits = 69 Lines analyzed = 3691 in approximately 0.23 seconds (16292 lines/second) Physical Source Lines of Code (SLOC) = 2984 Hits@level = [0] 26 [1] 17 [2] 30 [3] 13 [4] 9 [5] 0 Hits@level+ = [0+] 95 [1+] 69 [2+] 52 [3+] 22 [4+] 9 [5+] 0 Hits/KSLOC@level+ = [0+] 31.8365 [1+] 23.1233 [2+] 17.4263 [3+] 7.37265 [4+] 3.01609 [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.