]> granicus.if.org Git - procps-ng/commitdiff
library: strengthen <pids> sort order parameter checks
authorJim Warner <james.warner@comcast.net>
Mon, 28 Sep 2015 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Mon, 5 Oct 2015 10:32:54 +0000 (21:32 +1100)
The way that the passed sort order was validated would
allow the invalid 0 to fall between the sofa cushions.
So this patch will simply close that former oversight.

Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/pids.c

index 6be88d81801929ef0168d53da9c1dc6d38636ef8..a3229a152c71e0eb9baf59543a61b9d1c6600d0f 100644 (file)
@@ -1389,7 +1389,7 @@ PROCPS_EXPORT struct pids_stack **procps_pids_stacks_sort (
     // a pids_item is currently unsigned, but we'll protect our future
     if (sort < 0  || sort > PROCPS_PIDS_noop)
         return NULL;
-    if (order < -1  || order > +1)
+    if (order != PROCPS_SORT_ASCEND && order != PROCPS_SORT_DESCEND)
         return NULL;
     if (numstacked < 2)
         return stacks;