]> granicus.if.org Git - procps-ng/commitdiff
0064-ps/sortformat.c: Double-check chars in verify_short_sort().
authorQualys Security Advisory <qsa@qualys.com>
Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)
committerCraig Small <csmall@enc.com.au>
Sat, 9 Jun 2018 11:45:38 +0000 (21:45 +1000)
To avoid an out-of-bounds access at checkoff[tmp]. The strspn() at the
beginning of the function protects against it already, but double-check
this in case of some future change.

ps/sortformat.c

index b7974de6182a9321c8da8158cdcf2edb87f39a41..9637744221890c9c8a0dc7e1b91252e1f8805636 100644 (file)
@@ -427,6 +427,7 @@ static const char *verify_short_sort(const char *arg){
   walk = arg;
   for(;;){
     tmp = *walk;
+    if(tmp < 0 || (size_t)tmp >= sizeof(checkoff)) return _("bad sorting code");
     switch(tmp){
     case '\0':
       return NULL;   /* looks good */