]> granicus.if.org Git - procps-ng/commitdiff
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>
Fri, 18 May 2018 21:32:22 +0000 (07:32 +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 ace5fa704402ceb8e9c8b2f8dc22a00fba809cda..1594da624b27bdaa7b8229c2568939d375e0a02e 100644 (file)
@@ -428,6 +428,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 */