mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-10-03 15:29:29 +00:00
Don't accept trailing characters when validating numbers for --format
strtoull succeed when the leading characters of the input form a valid number, so it is necessary to verify that there is no trailing characters. Use the endptr parameter (that will point to the end of the accepted input) to verify that. Fixes #142. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
This commit is contained in:
committed by
Matthew Johnson
parent
49ec50f3da
commit
4a6796c47f
+3
-2
@@ -301,10 +301,11 @@ int set_version_url(char *url)
|
||||
static bool is_valid_integer_format(char *str)
|
||||
{
|
||||
unsigned long long int version;
|
||||
char *endptr = NULL;
|
||||
errno = 0;
|
||||
|
||||
version = strtoull(str, NULL, 10);
|
||||
if ((errno < 0) || (version == 0)) {
|
||||
version = strtoull(str, &endptr, 10);
|
||||
if ((errno < 0) || (version == 0) || (endptr && *endptr != '\0')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user