Przeglądaj źródła

Bug 557185 - Unterminated string after strncpy in Retro Changelog Plugin

According to the strncpy() manual, if there is no null byte among the
first n bytes of src, the string placed in dest will not be null
terminated. To fix the problem the null byte should be added manually.
Reviewed by: rmeggins
Pushed by: rmeggins
Endi S. Dewata 16 lat temu
rodzic
commit
9f91c67cfc
1 zmienionych plików z 1 dodań i 0 usunięć
  1. 1 0
      ldap/servers/plugins/retrocl/retrocl.c

+ 1 - 0
ldap/servers/plugins/retrocl/retrocl.c

@@ -358,6 +358,7 @@ static int retrocl_start (Slapi_PBlock *pb)
             } else {
                 retrocl_attributes[i] = slapi_ch_malloc(pos-value+1);
                 strncpy(retrocl_attributes[i], value, pos-value);
+                retrocl_attributes[i][pos-value] = NULL;
 
                 retrocl_aliases[i] = slapi_ch_malloc(value+length-pos);
                 strcpy(retrocl_aliases[i], pos+1);