From 7db637483b89817e14fc1fdb56ecc4ee07aaa33d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 18 May 2012 11:37:18 +0200 Subject: s3:idmap_cache: improve checks for format of value string in idmap_cache_find_sid2unixid() Autobuild-User: Michael Adam Autobuild-Date: Fri May 18 16:34:27 CEST 2012 on sn-devel-104 --- source3/lib/idmap_cache.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/source3/lib/idmap_cache.c b/source3/lib/idmap_cache.c index 0d792d456c..011a017c48 100644 --- a/source3/lib/idmap_cache.c +++ b/source3/lib/idmap_cache.c @@ -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)); -- cgit