backlight: check the lenght if the input before trimming '%'

Reported by:	hps
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D26693
This commit is contained in:
Baptiste Daroussin 2020-10-06 08:18:09 +00:00
parent 4d1308f49b
commit cf64bfef77
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=366472

View file

@ -145,7 +145,8 @@ main(int argc, char *argv[])
if (argc == 1) {
/* ignore a trailing % for user friendlyness */
if (argv[0][strlen(argv[0]) - 1] == '%')
if (strlen(argv[0]) > 0 &&
argv[0][strlen(argv[0]) - 1] == '%')
argv[0][strlen(argv[0]) - 1] = '\0';
percent = strtonum(argv[0], 0, 100, &percent_error);
if (percent_error)