[Pkg-tcltk-devel] Bug#440682: tcl8.4 has buggy memcmp.c

Ian Jackson iwj at ubuntu.com
Mon Sep 3 16:31:27 UTC 2007


Package: tcl8.4
Version: 8.4.15-1
Severity: important
Tags: patch

Seeing this warning
 /work/AutomatedTesting-packages/build/tcl8.4-8.4.15/unix/../compat/memcmp.c:55: warning: dereferencing 'void *' pointer

I went to look at the file memcmp.c and found a buggy implementation
of memcmp!  It will always return 0 if the first two bytes are the
same.

The patch below should be applied immediately and probably sent
upstream too.

I don't know why it's building the compat/memcmp.c when we have a
perfectly good memcmp.

Regards,
Ian.

--- tcl8.4-8.4.15/compat/memcmp.c~	2007-01-22 23:27:53.000000000 +0000
+++ tcl8.4-8.4.15/compat/memcmp.c	2007-09-03 17:20:53.000000000 +0100
@@ -43,16 +43,16 @@
  */
 
 int
-memcmp(s1, s2, n)
-    CONST VOID *s1;			/* First string. */
-    CONST VOID *s2;			/* Second string. */
+memcmp(s1_arg, s2_arg, n)
+    CONST VOID *s1_arg;			/* First string. */
+    CONST VOID *s2_arg;			/* Second string. */
     size_t      n;                      /* Length to compare. */
 {
-    CONST unsigned char *ptr1 = (CONST unsigned char *) s1;
-    CONST unsigned char *ptr2 = (CONST unsigned char *) s2;
+    CONST unsigned char *ptr1 = (CONST unsigned char *) s1_arg;
+    CONST unsigned char *ptr2 = (CONST unsigned char *) s2_arg;
 
     for ( ; n-- ; ptr1++, ptr2++) {
-	unsigned char u1 = *s1, u2 = *s2;
+	unsigned char u1 = *ptr1, u2 = *ptr2;
 
 	if ( u1 != u2) {
 	    return (u1-u2);




More information about the Pkg-tcltk-devel mailing list