From 3c20b3fc2464cec5b79e4e23037794be5826f536 Mon Sep 17 00:00:00 2001 From: "dejun.xdj" Date: Tue, 10 Apr 2018 17:05:48 +0800 Subject: [PATCH] Bugfix: xadd command ID parse strictly check the string to be converted, strtoull() in libc may not set errno to EINVAL when the string contains invalid digits. --- src/t_stream.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/t_stream.c b/src/t_stream.c index 4640f0b2..713b57b3 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -917,8 +917,10 @@ int string2ull(const char *s, unsigned long long *value) { return 1; } errno = 0; - *value = strtoull(s,NULL,10); - if (errno == EINVAL || errno == ERANGE) return 0; /* strtoull() failed. */ + char *endptr = NULL; + *value = strtoull(s,&endptr,10); + if (errno == EINVAL || errno == ERANGE || !(*s != '\0' && *endptr == '\0')) + return 0; /* strtoull() failed. */ return 1; /* Conversion done! */ }