Created
December 5, 2016 15:45
-
-
Save AndyNovo/34138a592390d30e5d607fc3d8439b96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hidden_Error__fscanf_strncpy_84_bad::hidden_Error__fscanf_strncpy_84_bad(int dataCopy) | |
{ | |
data = dataCopy; | |
/* POTENTIAL FLAW: Read data from the console using fscanf() */ | |
fscanf(stdin, "%d", &data); | |
} | |
hidden_Error__fscanf_strncpy_84_bad::~hidden_Error__fscanf_strncpy_84_bad() | |
{ | |
{ | |
char source[100]; | |
char dest[100] = ""; | |
memset(source, 'A', 100-1); | |
source[100-1] = '\0'; | |
if (data < 100) | |
{ | |
strncpy(dest, source, data); | |
dest[data] = '\0'; /* strncpy() does not always NULL terminate */ | |
} | |
printLine(dest); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment