array overflow in local.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
gcc found a problem in our native/jni/javanet/local.c.

I changed it to what I think makes sense but I am not sure whether this
is still the intended behavior.

Furthermore since overrunning the bounds of a stack allocated array may
trash other stuff on the stack I wonder whether this fix also prevents
the problem that the workaround above the modified code speaks of. Since
I do not run Darwin-based OS I cannot test it myself.

Regards
Robert
Index: classpath-0.96.1/native/jni/java-net/local.c
===================================================================
--- classpath-0.96.1.orig/native/jni/java-net/local.c	2008-06-27 11:21:31.000000000 +0200
+++ classpath-0.96.1/native/jni/java-net/local.c	2008-06-27 11:21:41.000000000 +0200
@@ -93,7 +93,7 @@
     }
 
   strncpy (saddr.sun_path, addr, sizeof (saddr.sun_path));
-  saddr.sun_path[sizeof (saddr.sun_path)] = '\0';
+  saddr.sun_path[sizeof (saddr.sun_path) - 1] = '\0';
   saddr.sun_family = AF_LOCAL;
 
   return bind (fd, (struct sockaddr *) &saddr, SUN_LEN (&saddr));

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux