Content deleted Content added
Fixed a bug in the "secure_copy" function. strlen returns size_t and not int. |
|||
Line 21:
int secure_function(char * user_input) {
char dst[BUF_SIZE];
// copy a maximum of BUF_SIZE bytes
strncpy(dst, user_input,BUF_SIZE);
}
Line 28:
size_t len = strlen(src);
char * dst = (char *) malloc(len + 1);
if (dst != NULL) {
strncpy(dst, src, len);
// append null terminator
dst[len] = '\0';
}
|