kfw fixes: fix _snprintf usage; use full error code in leash_error_message
authorTom Yu <tlyu@mit.edu>
Mon, 12 Dec 2011 20:45:58 +0000 (20:45 +0000)
committerTom Yu <tlyu@mit.edu>
Mon, 12 Dec 2011 20:45:58 +0000 (20:45 +0000)
Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>
ticket: 7050

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25562 dc483132-0cff-0310-8789-dd5450dbe970

src/windows/leashdll/lshfunc.c

index 6f2756672f00034696e182f6dd074e7f788f2ce0..1a0bf143059b170db2e60fde7a79126600883714 100644 (file)
@@ -68,7 +68,7 @@ leash_error_message(
 {
     char message[2048];
     char *p = message;
-    int size = sizeof(message);
+    int size = sizeof(message) - 1; /* -1 to leave room for NULL terminator */
     int n;
 
     // XXX: ignore AFS for now.
@@ -85,7 +85,7 @@ leash_error_message(
         n = _snprintf(p, size,
                       "Kerberos 5: %s (error %ld)\n",
                       perror_message(rc5),
-                      rc5 & 255 // XXX: & 255??!!!
+                      rc5
             );
         p += n;
         size -= n;
@@ -109,6 +109,7 @@ leash_error_message(
         size -= n;
     }
 #ifdef USE_MESSAGE_BOX
+    *p = 0; /* ensure NULL termination of message */
     if ( displayMB )
         MessageBox(NULL, message, "Leash", MB_OK | MB_ICONERROR | MB_TASKMODAL |
                     MB_SETFOREGROUND);