parent
0d945abdb6
commit
ce0ae746d8
@ -0,0 +1,60 @@
|
|||||||
|
diff --git a/ps/parser.c b/ps/parser.c
|
||||||
|
index 4263a1f..b33f319 100644
|
||||||
|
--- a/ps/parser.c
|
||||||
|
+++ b/ps/parser.c
|
||||||
|
@@ -31,7 +31,7 @@
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
-#include "../proc/alloc.h"
|
||||||
|
+#include "xalloc.h"
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "c.h"
|
||||||
|
@@ -184,8 +184,8 @@ static const char *parse_list(const char *arg, const char *(*parse_fn)(char *, s
|
||||||
|
const char *err; /* error code that could or did happen */
|
||||||
|
/*** prepare to operate ***/
|
||||||
|
node = malloc(sizeof(selection_node));
|
||||||
|
- node->u = malloc(strlen(arg)*sizeof(sel_union)); /* waste is insignificant */
|
||||||
|
node->n = 0;
|
||||||
|
+ node->u = NULL;
|
||||||
|
buf = strdup(arg);
|
||||||
|
/*** sanity check and count items ***/
|
||||||
|
need_item = 1; /* true */
|
||||||
|
@@ -199,12 +199,13 @@ static const char *parse_list(const char *arg, const char *(*parse_fn)(char *, s
|
||||||
|
need_item=1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
- if(need_item) items++;
|
||||||
|
+ if(need_item && items<INT_MAX) items++;
|
||||||
|
need_item=0;
|
||||||
|
}
|
||||||
|
} while (*++walk);
|
||||||
|
if(need_item) goto parse_error;
|
||||||
|
node->n = items;
|
||||||
|
+ node->u = xcalloc(items, sizeof(sel_union));
|
||||||
|
/*** actually parse the list ***/
|
||||||
|
walk = buf;
|
||||||
|
while(items--){
|
||||||
|
@@ -1031,15 +1032,15 @@ static const char *parse_trailing_pids(void){
|
||||||
|
thisarg = ps_argc - 1; /* we must be at the end now */
|
||||||
|
|
||||||
|
pidnode = malloc(sizeof(selection_node));
|
||||||
|
- pidnode->u = malloc(i*sizeof(sel_union)); /* waste is insignificant */
|
||||||
|
+ pidnode->u = xcalloc(i, sizeof(sel_union)); /* waste is insignificant */
|
||||||
|
pidnode->n = 0;
|
||||||
|
|
||||||
|
grpnode = malloc(sizeof(selection_node));
|
||||||
|
- grpnode->u = malloc(i*sizeof(sel_union)); /* waste is insignificant */
|
||||||
|
+ grpnode->u = xcalloc(i, sizeof(sel_union)); /* waste is insignificant */
|
||||||
|
grpnode->n = 0;
|
||||||
|
|
||||||
|
sidnode = malloc(sizeof(selection_node));
|
||||||
|
- sidnode->u = malloc(i*sizeof(sel_union)); /* waste is insignificant */
|
||||||
|
+ sidnode->u = xcalloc(i, sizeof(sel_union)); /* waste is insignificant */
|
||||||
|
sidnode->n = 0;
|
||||||
|
|
||||||
|
while(i--){
|
||||||
|
--
|
||||||
|
2.40.1
|
||||||
|
|
@ -0,0 +1,12 @@
|
|||||||
|
diff -up ./sysctl.c.old ./sysctl.c
|
||||||
|
--- ./sysctl.c.old 2023-07-20 14:43:10.271856721 +0200
|
||||||
|
+++ ./sysctl.c 2023-07-21 14:50:39.792368077 +0200
|
||||||
|
@@ -578,7 +578,7 @@ static int WriteSetting(
|
||||||
|
}
|
||||||
|
if ((rc == EXIT_SUCCESS && !Quiet) || DryRun) {
|
||||||
|
if (NameOnly) {
|
||||||
|
- printf("%s\n", value);
|
||||||
|
+ printf("%s\n", dotted_key);
|
||||||
|
} else {
|
||||||
|
if (PrintName) {
|
||||||
|
printf("%s = %s\n", dotted_key, value);
|
Loading…
Reference in new issue