Revision: 14717
Author: adrian.chadd
Date: Tue Jun 22 01:55:05 2010
Log: Make sure there's enough space in the buffer before adding to it.


http://code.google.com/p/lusca-cache/source/detail?r=14717

Modified:
 /branches/LUSCA_HEAD/libsqinet/sqinet.c

=======================================
--- /branches/LUSCA_HEAD/libsqinet/sqinet.c     Mon May 10 19:56:12 2010
+++ /branches/LUSCA_HEAD/libsqinet/sqinet.c     Tue Jun 22 01:55:05 2010
@@ -705,14 +705,12 @@
                        s6 = a6.s6_addr;
                        r = 0;
                        for (i = 0; i < 16; i++) {
-                               printf("  %d: got %X\n", i, s6[i]);
- r += snprintf(buf + r, len - r, "%x.%x.", s6[i] & 0x0f, (s6[i] >> 4) & 0x0f);
-                               /* Make sure we've got space for the ip6.arpa 
bit at the end */
-                               if (r + 10 >= len) {
+                               /* Make sure we've got space for this AND the 
.ip6.arpa at the end */
+                               if (r + 16 >= len) {
                                        return 0;
                                }
-                       }
-                       /* XXX this is very risky and doesn't verify there's 
space left! */
+ r += snprintf(buf + r, len - r, "%x.%x.", s6[i] & 0x0f, (s6[i] >> 4) & 0x0f);
+                       }
                        strcat(buf + r, "ip6.arpa");
                        return r + 8;
                        break;

--
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en.

Reply via email to