]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
os400sys: replace `strcpy()` with `memcpy()` master
authorViktor Szakats <commit@vsz.me>
Wed, 24 Dec 2025 00:13:19 +0000 (01:13 +0100)
committerViktor Szakats <commit@vsz.me>
Wed, 24 Dec 2025 22:53:40 +0000 (23:53 +0100)
Source and target are the same size, null-terminator is already present
in the target buffer.

Closes #20089

packages/OS400/os400sys.c

index f3da1a4105a83809cd2e22c15e66ff69e2003f87..3ae28205dde9e56ccd9c976f5ba03ed60131bbc8 100644 (file)
@@ -705,14 +705,14 @@ char *Curl_ldap_get_dn_a(void *ld, LDAPMessage *entry)
     return cp2;
 
   QadrtConvertE2A(cp2, cp, i, i);
-  cp2[i] = '\0';
 
   /* No way to allocate a buffer here, because it will be released by
      ldap_memfree() and ldap_memalloc() does not exist. The solution is to
-     overwrite the EBCDIC buffer with ASCII to return it. */
+     overwrite the EBCDIC buffer with ASCII to return it.
 
-  /* !checksrc! disable BANNEDFUNC 1 */
-  strcpy(cp, cp2);
+     The destination buffer already has a null-terminator at the correct
+     position. Keep it outouched and copy the buffer without a terminator. */
+  memcpy(cp, cp2, i);
   free(cp2);
   return cp;
 }
@@ -736,14 +736,14 @@ char *Curl_ldap_first_attribute_a(void *ld, LDAPMessage *entry,
     return cp2;
 
   QadrtConvertE2A(cp2, cp, i, i);
-  cp2[i] = '\0';
 
   /* No way to allocate a buffer here, because it will be released by
      ldap_memfree() and ldap_memalloc() does not exist. The solution is to
-     overwrite the EBCDIC buffer with ASCII to return it. */
+     overwrite the EBCDIC buffer with ASCII to return it.
 
-  /* !checksrc! disable BANNEDFUNC 1 */
-  strcpy(cp, cp2);
+     The destination buffer already has a null-terminator at the correct
+     position. Keep it outouched and copy the buffer without a terminator. */
+  memcpy(cp, cp2, i);
   free(cp2);
   return cp;
 }
@@ -767,14 +767,14 @@ char *Curl_ldap_next_attribute_a(void *ld, LDAPMessage *entry,
     return cp2;
 
   QadrtConvertE2A(cp2, cp, i, i);
-  cp2[i] = '\0';
 
   /* No way to allocate a buffer here, because it will be released by
      ldap_memfree() and ldap_memalloc() does not exist. The solution is to
-     overwrite the EBCDIC buffer with ASCII to return it. */
+     overwrite the EBCDIC buffer with ASCII to return it.
 
-  /* !checksrc! disable BANNEDFUNC 1 */
-  strcpy(cp, cp2);
+     The destination buffer already has a null-terminator at the correct
+     position. Keep it outouched and copy the buffer without a terminator. */
+  memcpy(cp, cp2, i);
   free(cp2);
   return cp;
 }