]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Catch more strtol() failures when using KEYRINGs
authorNalin Dahyabhai <nalin@dahyabhai.net>
Mon, 11 Nov 2013 18:10:08 +0000 (13:10 -0500)
committerGreg Hudson <ghudson@mit.edu>
Tue, 12 Nov 2013 16:13:51 +0000 (11:13 -0500)
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@mit.edu: simplified slightly]

ticket: 7764 (new)
target_version: 1.12
tags: pullup

src/lib/krb5/ccache/cc_keyring.c

index 795ccd63c7f0ac23dd764cc6550342e459765413..a07a0dc50d05f50b8b373588bd65a3abe7c234e2 100644 (file)
@@ -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();