svn rev #25367: trunk/src/include/

ghudson@MIT.EDU ghudson at MIT.EDU
Tue Oct 18 12:32:28 EDT 2011


http://src.mit.edu/fisheye/changelog/krb5/?cs=25367
Commit By: ghudson
Log Message:
ticket: 6980
subject: Ensure termination in Windows vsnprintf wrapper
target_version: 1.10
tags: pullup

The Windows _vsnprintf does not terminate its output buffer in the
overflow case.  Make sure we do that in the wrapper.  Reported by
Chris Hecker.

(Not an issue for KfW 3.2 since we weren't using snprintf in 1.6.x
except in Unix-specific code.)


Changed Files:
U   trunk/src/include/k5-platform.h
Modified: trunk/src/include/k5-platform.h
===================================================================
--- trunk/src/include/k5-platform.h	2011-10-17 22:55:44 UTC (rev 25366)
+++ trunk/src/include/k5-platform.h	2011-10-18 16:32:28 UTC (rev 25367)
@@ -958,8 +958,10 @@
     va_copy(args_copy, args);
     length = _vscprintf(format, args_copy);
     va_end(args_copy);
-    if (size)
+    if (size > 0) {
         _vsnprintf(str, size, format, args);
+        str[size - 1] = '\0';
+    }
     return length;
 }
 static inline int




More information about the cvs-krb5 mailing list