The _afscrypto_strdup helper function was failing to alloc enough
space for the string's trailing NUL, and to copy that NUL over.
Caught by coverity (#985580)
Change-Id: I61c9a96275a79682a9521846ab52615ea5bc061d
Reviewed-on: http://gerrit.openafs.org/9263
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
_afscrypto_strdup(const char *str) {
char *ptr;
- ptr = malloc(strlen(str));
+ ptr = malloc(strlen(str) + 1);
if (ptr == NULL)
return ptr;
- memcpy(ptr, str, strlen(str));
+ memcpy(ptr, str, strlen(str) + 1);
return ptr;
}