Browse Source

fix a couple of minor coverity issues

12432 Copy into fixed size buffer
In msgIdAdd(): A source buffer of statically unknown size is copied into a fixed size destination buffer

12428 Copy into fixed size buffer
In doDeleteEntry(): A source buffer of statically unknown size is copied into a fixed size destination buffer

Reviewed by: mreynold (Thanks!)
Rich Megginson 14 years ago
parent
commit
c493fb4f75

+ 2 - 3
ldap/servers/slapd/tools/ldclt/ldapfct.c

@@ -3668,9 +3668,8 @@ doDeleteEntry (
      */
     if (buildRandomRdnOrFilter (tttctx) < 0)
       return (-1);
-    strcpy (delDn, tttctx->bufFilter);
-    strcat (delDn, ",");
-    strcat (delDn, tttctx->bufBaseDN);
+    snprintf (delDn, sizeof(delDn), "%s,%s", tttctx->bufFilter, tttctx->bufBaseDN);
+    delDn[sizeof(delDn)-1] = '\0';
 
     ret = ldap_delete_ext (tttctx->ldapCtx, delDn, NULL, NULL, &msgid);
     if (ret < 0)

+ 2 - 1
ldap/servers/slapd/tools/ldclt/threadMain.c

@@ -626,7 +626,8 @@ msgIdAdd (
    */
   tttctx->lastMsgId->next  = NULL;
   tttctx->lastMsgId->msgid = msgid;
-  strcpy (tttctx->lastMsgId->str, str);
+  strncpy (tttctx->lastMsgId->str, str, sizeof(tttctx->lastMsgId->str));
+  tttctx->lastMsgId->str[sizeof(tttctx->lastMsgId->str)-1] = '\0';
   strncpy (tttctx->lastMsgId->dn, dn, sizeof(tttctx->lastMsgId->dn));
   tttctx->lastMsgId->dn[sizeof(tttctx->lastMsgId->dn)-1] = '\0';
   tttctx->lastMsgId->attribs = attribs;