k5_utf8s_to_ucs2s could deref NULL pointer..
authorTom Yu <tlyu@mit.edu>
Wed, 15 Apr 2009 20:07:37 +0000 (20:07 +0000)
committerTom Yu <tlyu@mit.edu>
Wed, 15 Apr 2009 20:07:37 +0000 (20:07 +0000)
pull up r22177 from trunk

 ------------------------------------------------------------------------
 r22177 | epeisach | 2009-04-07 19:59:25 -0400 (Tue, 07 Apr 2009) | 10 lines
 Changed paths:
    M /trunk/src/util/support/utf8_conv.c

 ticket:
 Subject k5_utf8s_to_ucs2s could deref NULL pointer...

 Based on usage of this static function, this will never happen as
 results are always malloced (and checked) by caller.  However, the
 function is already coded to handle the first argument being null - so
 be consistent throughout.

ticket: 6468
version_fixed: 1.7
tags: pullup
target_version: 1.7

git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-7@22251 dc483132-0cff-0310-8789-dd5450dbe970

src/util/support/utf8_conv.c

index 531b3d2d20f2eaa683742d5573869b9985671766..15e4521ccfcff5f5229999ecffc446127e79b585 100644 (file)
@@ -118,9 +118,11 @@ k5_utf8s_to_ucs2s(krb5_ucs2 *ucs2str,
     }
 
     assert(ucs2len < count);
-
-    /* Add null terminator if there's room in the buffer. */
-    ucs2str[ucs2len] = 0;
+    
+    if (ucs2str != NULL) {
+       /* Add null terminator if there's room in the buffer. */
+       ucs2str[ucs2len] = 0;
+    }
 
     return ucs2len;
 }