bcopy must DIE ! Stop people creeping use of bcopy back into the code
authorJeremy Allison <jra@samba.org>
Tue, 26 Feb 2002 17:40:43 +0000 (17:40 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 26 Feb 2002 17:40:43 +0000 (17:40 +0000)
(and yes I know who you are..... :-).
Jeremy.
(This used to be commit 330b0df960329bcf4696b8fa4a7357e6c456f74e)

source3/include/safe_string.h
source3/lib/hmacmd5.c
source3/libsmb/clidgram.c
source3/libsmb/libsmbclient.c

index 487174dec3cfb041898d6b9ec6a6583cfa470042..1ee97833c5d3273fbbbc17ac6ee8235f0f74b2b1 100644 (file)
 /* Some macros to ensure people don't use buffer overflow vulnerable string
    functions. */
 
+#ifdef bcopy
+#undef bcopy
+#endif /* bcopy */
+#define bcopy(src,dest,size) __ERROR__XX__NEVER_USE_BCOPY___;
+
 #ifdef strcpy
 #undef strcpy
 #endif /* strcpy */
index e4a5995e11686df55d1ed6233db8ac2756d900bd..f436fd30c0e8e67c20ce550e96ae8dd0535e2c34 100644 (file)
@@ -49,8 +49,8 @@ void hmac_md5_init_rfc2104(uchar*  key, int key_len, HMACMD5Context *ctx)
         /* start out by storing key in pads */
         ZERO_STRUCT(ctx->k_ipad);
         ZERO_STRUCT(ctx->k_opad);
-        bcopy( key, ctx->k_ipad, key_len);
-        bcopy( key, ctx->k_opad, key_len);
+        memcpy( ctx->k_ipad, key, key_len);
+        memcpy( ctx->k_opad, key, key_len);
 
         /* XOR key with ipad and opad values */
         for (i=0; i<64; i++)
@@ -80,12 +80,11 @@ void hmac_md5_init_limK_to_64(const uchar* key, int key_len,
         /* start out by storing key in pads */
         ZERO_STRUCT(ctx->k_ipad);
         ZERO_STRUCT(ctx->k_opad);
-        bcopy( key, ctx->k_ipad, key_len);
-        bcopy( key, ctx->k_opad, key_len);
+        memcpy( ctx->k_ipad, key, key_len);
+        memcpy( ctx->k_opad, key, key_len);
 
         /* XOR key with ipad and opad values */
-        for (i=0; i<64; i++)
-       {
+        for (i=0; i<64; i++) {
                 ctx->k_ipad[i] ^= 0x36;
                 ctx->k_opad[i] ^= 0x5c;
         }
index 0b07bc2c990daf03b10b9ec5c699faf6ec2b0841..abade68b0122ebc4af2c68a190e13befba726c0a 100644 (file)
@@ -117,7 +117,7 @@ int cli_get_response(int dgram_sock, BOOL unique, char *mailslot, char *buf, int
 
     /* Copy the data to buffer, respecting sizes ... */
 
-    bcopy(&dgram->data[92], buf, MIN(bufsiz, (dgram->datasize - 92)));
+    memset(buf, &dgram->data[92], MIN(bufsiz, (dgram->datasize - 92)));
 
   }
   else 
index 67e95d09d7b7786c3ce490f99f103c7155315391..01b418655338496182e64a4f785666c22f8703ba 100644 (file)
@@ -1908,7 +1908,7 @@ struct smbc_dirent *smbc_readdir(unsigned int fd)
 
                /* Hmmm, do I even need to copy it? */
 
-               bcopy(dirent, smbc_local_dirent, dirent->dirlen); /* Copy the dirent */
+               memcpy(smbc_local_dirent, dirent, dirent->dirlen); /* Copy the dirent */
 
                dirp = (struct smbc_dirent *)smbc_local_dirent;
 
@@ -2000,7 +2000,7 @@ int smbc_getdents(unsigned int fd, struct smbc_dirent *dirp, int count)
 
                dirent = dir->dirent;
 
-               bcopy(dirent, ndir, reqd); /* Copy the data in ... */
+               memcpy(ndir, dirent, reqd); /* Copy the data in ... */
     
                ((struct smbc_dirent *)ndir)->comment = 
                        (char *)(&((struct smbc_dirent *)ndir)->name + dirent->namelen + 1);