Skip to content

Instantly share code, notes, and snippets.

@AndyNovo
Created December 5, 2016 15:45
Show Gist options
  • Save AndyNovo/34138a592390d30e5d607fc3d8439b96 to your computer and use it in GitHub Desktop.
Save AndyNovo/34138a592390d30e5d607fc3d8439b96 to your computer and use it in GitHub Desktop.
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