]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Make sure copied strings are properly terminated in snmplib and wccp2
authorThomas Hozza <thozza@redhat.com>
Wed, 2 Jan 2013 03:34:31 +0000 (20:34 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 2 Jan 2013 03:34:31 +0000 (20:34 -0700)
snmplib/parse.c
src/wccp2.cc

index 740b594c1a882c2880b2c3b306e91b9142eb9eb7..352af377a486f00eff5389b57c8785de4e0159b8 100644 (file)
@@ -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) {
index e4cd968a34019dc0b35e6e57254e1a807dcbd6b8..6cb126d8fda991115e241bf866d45cbd0288a072 100644 (file)
@@ -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);