b9f1262d777a7a6af9f514e6efaf22ce886e0a0d
hiram
  Mon Jun 20 10:44:02 2011 -0700
a bit of extra information on the buffer overflow message to maybe help locate the message short of a stack dump at this point
diff --git src/lib/common.c src/lib/common.c
index f5cccf1..38c354b 100644
--- src/lib/common.c
+++ src/lib/common.c
@@ -3082,31 +3082,34 @@
 freeMem(haystackCopy);
 freeMem(needleCopy);
 
 if(p==NULL) return NULL;
 
 return p-q+haystack;
 }
 
 int vasafef(char* buffer, int bufSize, char *format, va_list args)
 /* Format string to buffer, vsprintf style, only with buffer overflow
  * checking.  The resulting string is always terminated with zero byte. */
 {
 int sz = vsnprintf(buffer, bufSize, format, args);
 /* note that some version return -1 if too small */
 if ((sz < 0) || (sz >= bufSize))
-    errAbort("buffer overflow, size %d, format: %s", bufSize, format);
+    {
+    buffer[bufSize-1] = (char) 0;
+    errAbort("buffer overflow, size %d, format: %s, buffer: '%s'", bufSize, format, buffer);
+    }
 return sz;
 }
 
 int safef(char* buffer, int bufSize, char *format, ...)
 /* Format string to buffer, vsprintf style, only with buffer overflow
  * checking.  The resulting string is always terminated with zero byte. */
 {
 int sz;
 va_list args;
 va_start(args, format);
 sz = vasafef(buffer, bufSize, format, args);
 va_end(args);
 return sz;
 }