[Pcre-svn] [499] code/trunk/src/pcre2test.c: Further small f…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [499] code/trunk/src/pcre2test.c: Further small fix to regerror() overflow handling, to ensure identical output
Revision: 499
          http://www.exim.org/viewvc/pcre2?view=rev&revision=499
Author:   ph10
Date:     2016-02-28 13:33:55 +0000 (Sun, 28 Feb 2016)
Log Message:
-----------
Further small fix to regerror() overflow handling, to ensure identical output 
whether or not there is a zero at the end of the buffer.


Modified Paths:
--------------
    code/trunk/src/pcre2test.c


Modified: code/trunk/src/pcre2test.c
===================================================================
--- code/trunk/src/pcre2test.c    2016-02-27 12:49:00 UTC (rev 498)
+++ code/trunk/src/pcre2test.c    2016-02-28 13:33:55 UTC (rev 499)
@@ -4779,8 +4779,12 @@
     if (bsize + 8 < pbuffer8_size)
       memcpy(pbuffer8 + bsize, "DEADBEEF", 8);
     usize = regerror(rc, &preg, (char *)pbuffer8, bsize);
+    
+    /* Inside regerror(), snprintf() is used. If the buffer is too small, some 
+    versions of snprintf() put a zero byte at the end, but others do not. 
+    Therefore, we print a maximum of one less than the size of the buffer. */


-    psize = (int)bsize;
+    psize = (int)bsize - 1;
     fprintf(outfile, "Failed: POSIX code %d: %.*s\n", rc, psize, pbuffer8);
     if (usize > bsize)
       {