Add length check on command line input

This commit is contained in:
Celine Lee 2022-04-04 17:57:24 -04:00 committed by GitHub
parent 2f95139c77
commit 4a9ae83d64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,7 +11,7 @@ int main(int argc, char **argv)
return 1;
}
if (argv[1][0] == '-' && argv[1][1] == '6')
if (strlen(argv[1]) > 1 && argv[1][0] == '-' && argv[1][1] == '6')
{
struct utsname buf;
if (0 == uname(&buf))