File procps-ng-3.3.12-sysctl-a.patch of Package procps

From a89cebe1970fb0cd87d71e4524d6620c2b673369 Mon Sep 17 00:00:00 2001
From: Werner Fink <werner@suse.de>
Date: Mon, 22 May 2017 12:17:53 +0200
Subject: [PATCH] Allow sysctl to print lines longer than 1024 chars

as well do not open /proc/sys files if only the names of the
system control names of the kernel parameters should be shown.
Avoid leaking tmpname in case of a pattern mismatch.

Signed-off-by: Werner Fink <werner@suse.de>
---
 sysctl.c |   42 ++++++++++++++++++++++++------------------
 1 file changed, 24 insertions(+), 18 deletions(-)

--- sysctl.c
+++ sysctl.c	2017-07-06 08:11:02.011136954 +0000
@@ -211,8 +211,13 @@ static int ReadSetting(const char *restr
 	}
 
 	if (pattern && !pattern_match(outname, pattern)) {
-		free(outname);
-		return 0;
+		rc = 0;
+		goto out;
+	}
+
+	if (NameOnly) {
+		fprintf(stdout, "%s\n", outname);
+		goto out;
 	}
 
 	fp = fopen(tmpname, "r");
@@ -241,24 +246,25 @@ static int ReadSetting(const char *restr
 			 * /sbin/sysctl -a | egrep -6 dev.cdrom.info
 			 */
 			do {
-				if (NameOnly) {
-					fprintf(stdout, "%s\n", outname);
-				} else {
-					/* already has the \n in it */
-					if (PrintName) {
-						fprintf(stdout, "%s = %s",
-							outname, inbuf);
-						if (inbuf[strlen(inbuf) - 1] != '\n')
-							putchar('\n');
-					} else {
-						if (!PrintNewline) {
-							char *nlptr =
-							    strchr(inbuf, '\n');
-							if (nlptr)
-								*nlptr = '\0';
-						}
+				char *nlptr;
+				if (PrintName) {
+					fprintf(stdout, "%s = ", outname);
+					do {
 						fprintf(stdout, "%s", inbuf);
+						nlptr = &inbuf[strlen(inbuf) - 1];
+						/* already has the \n in it */
+						if (*nlptr == '\n')
+							break;
+					} while (fgets(inbuf, sizeof inbuf - 1, fp));
+					if (*nlptr != '\n')
+						putchar('\n');
+				} else {
+					if (!PrintNewline) {
+						nlptr = strchr(inbuf, '\n');
+						if (nlptr)
+							*nlptr = '\0';
 					}
+					fprintf(stdout, "%s", inbuf);
 				}
 			} while (fgets(inbuf, sizeof inbuf - 1, fp));
 		} else {
openSUSE Build Service is sponsored by