From 961fcc63640ee95e9b1cfebe92d71e3b9f3d9f52 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Thu, 21 Feb 2013 16:18:26 +0000 Subject: [PATCH] crypto: _afscrypto_strdup must copy trailing NUL 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 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/crypto/hcrypto/kernel/alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crypto/hcrypto/kernel/alloc.c b/src/crypto/hcrypto/kernel/alloc.c index 158d3bd75..794d860db 100644 --- a/src/crypto/hcrypto/kernel/alloc.c +++ b/src/crypto/hcrypto/kernel/alloc.c @@ -55,10 +55,10 @@ char* _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; } -- 2.39.5