From 2e668fd9b0211029be4133dfcb4593fc742f3ac5 Mon Sep 17 00:00:00 2001 From: Thomas Hozza Date: Tue, 1 Jan 2013 20:34:31 -0700 Subject: [PATCH] Make sure copied strings are properly terminated in snmplib and wccp2 --- snmplib/parse.c | 1 + src/wccp2.cc | 2 ++ 2 files changed, 3 insertions(+) diff --git a/snmplib/parse.c b/snmplib/parse.c index 740b594c1a..352af377a4 100644 --- a/snmplib/parse.c +++ b/snmplib/parse.c @@ -1008,6 +1008,7 @@ parse(FILE *fp) { return NULL; } strncpy(name, token, 64); + name[63] = '\0'; type = get_token(fp, token); if (type == OBJTYPE) { if (root == NULL) { diff --git a/src/wccp2.cc b/src/wccp2.cc index e4cd968a34..6cb126d8fd 100644 --- a/src/wccp2.cc +++ b/src/wccp2.cc @@ -584,6 +584,7 @@ wccp2_update_md5_security(char *password, char *ptr, char *packet, int len) /* The password field, for the MD5 hash, needs to be 8 bytes and NUL padded. */ memset(pwd, 0, sizeof(pwd)); strncpy(pwd, password, sizeof(pwd)); + pwd[sizeof(pwd) - 1] = '\0'; ws = (struct wccp2_security_md5_t *) ptr; assert(ntohs(ws->security_type) == WCCP2_SECURITY_INFO); @@ -651,6 +652,7 @@ wccp2_check_security(struct wccp2_service_list_t *srv, char *security, char *pac /* The password field, for the MD5 hash, needs to be 8 bytes and NUL padded. */ memset(pwd, 0, sizeof(pwd)); strncpy(pwd, srv->wccp_password, sizeof(pwd)); + pwd[sizeof(pwd) - 1] = '\0'; /* Take a copy of the challenge: we need to NUL it before comparing */ memcpy(md5_challenge, ws->security_implementation, 16); -- 2.47.2