krb5 commit [krb5-1.12]: Catch more strtol() failures when using KEYRINGs

Tom Yu tlyu at MIT.EDU
Wed Nov 13 14:48:19 EST 2013


https://github.com/krb5/krb5/commit/b9587b53d09cea8ff8625bcda12815eff359f6d6
commit b9587b53d09cea8ff8625bcda12815eff359f6d6
Author: Nalin Dahyabhai <nalin at dahyabhai.net>
Date:   Mon Nov 11 13:10:08 2013 -0500

    Catch more strtol() failures when using KEYRINGs
    
    When parsing what should be a UID while resolving a KEYRING ccache
    name, don't just depend on strtol() to set errno when the residual
    that we pass to it can't be parsed as a number.  In addition to
    checking errno, pass in and check the value of an "endptr".
    
    [ghudson at mit.edu: simplified slightly]
    
    (cherry picked from commit 5ac159e220297a8f62dd5edcec6f9b988b0627ea)
    
    ticket: 7764
    version_fixed: 1.12
    status: resolved

 src/lib/krb5/ccache/cc_keyring.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/lib/krb5/ccache/cc_keyring.c b/src/lib/krb5/ccache/cc_keyring.c
index 795ccd6..a07a0dc 100644
--- a/src/lib/krb5/ccache/cc_keyring.c
+++ b/src/lib/krb5/ccache/cc_keyring.c
@@ -593,7 +593,7 @@ get_collection(const char *anchor_name, const char *collection_name,
 {
     krb5_error_code ret;
     key_serial_t persistent_id, anchor_id, possess_id = 0;
-    char *ckname;
+    char *ckname, *cnend;
     long uidnum;
 
     *collection_id_out = 0;
@@ -607,8 +607,8 @@ get_collection(const char *anchor_name, const char *collection_name,
          */
         if (*collection_name != '\0') {
             errno = 0;
-            uidnum = strtol(collection_name, NULL, 10);
-            if (errno)
+            uidnum = strtol(collection_name, &cnend, 10);
+            if (errno || *cnend != '\0')
                 return KRB5_KCC_INVALID_UID;
         } else {
             uidnum = geteuid();


More information about the cvs-krb5 mailing list