diff options
-rw-r--r-- | src/basic/util.c | 5 | ||||
-rw-r--r-- | src/test/test-util.c | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/basic/util.c b/src/basic/util.c index beec7cb7dd..86aacad307 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -403,7 +403,10 @@ int parse_uid(const char *s, uid_t* ret_uid) { return -ERANGE; if (!uid_is_valid(uid)) - return -ENXIO; + return -ENXIO; /* we return ENXIO instead of EINVAL + * here, to make it easy to distuingish + * invalid numeric uids invalid + * strings. */ if (ret_uid) *ret_uid = uid; diff --git a/src/test/test-util.c b/src/test/test-util.c index dff38ab6f6..10d8d210d5 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -282,6 +282,9 @@ static void test_parse_uid(void) { r = parse_uid("65535", &uid); assert_se(r == -ENXIO); + + r = parse_uid("asdsdas", &uid); + assert_se(r == -EINVAL); } static void test_safe_atou16(void) { |