s3:idmap_cache: improve checks for format of value string in idmap_cache_find_sid2uni...
authorMichael Adam <obnox@samba.org>
Fri, 18 May 2012 09:37:18 +0000 (11:37 +0200)
committerMichael Adam <obnox@samba.org>
Fri, 18 May 2012 14:34:27 +0000 (16:34 +0200)
Autobuild-User: Michael Adam <obnox@samba.org>
Autobuild-Date: Fri May 18 16:34:27 CEST 2012 on sn-devel-104

source3/lib/idmap_cache.c

index 0d792d456cabec39000aafd13603ee4ce12ee935..011a017c483959addd2688f2da6064174ec42c81 100644 (file)
@@ -55,7 +55,22 @@ bool idmap_cache_find_sid2unixid(const struct dom_sid *sid, struct unixid *id,
 
        DEBUG(10, ("Parsing value for key [%s]: value=[%s]\n", key, value));
 
+       if (value[0] == '\0') {
+               DEBUG(0, ("Failed to parse value for key [%s]: "
+                         "value is empty\n", key));
+               ret = false;
+               goto done;
+       }
+
        tmp_id.id = strtol(value, &endptr, 10);
+
+       if ((value == endptr) && (tmp_id.id == 0)) {
+               DEBUG(0, ("Failed to parse value for key [%s]: value[%s] does "
+                         "not start with a number\n", key, value));
+               ret = false;
+               goto done;
+       }
+
        DEBUG(10, ("Parsing value for key [%s]: id=[%llu], endptr=[%s]\n",
                   key, (unsigned long long)tmp_id.id, endptr));