sysctl: 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>
This commit is contained in:
parent
aa41c309dd
commit
e04394ef24
30
sysctl.c
30
sysctl.c
@ -207,8 +207,13 @@ static int ReadSetting(const char *restrict const name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pattern && !pattern_match(outname, pattern)) {
|
if (pattern && !pattern_match(outname, pattern)) {
|
||||||
free(outname);
|
rc = 0;
|
||||||
return 0;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NameOnly) {
|
||||||
|
fprintf(stdout, "%s\n", outname);
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = fopen(tmpname, "r");
|
fp = fopen(tmpname, "r");
|
||||||
@ -237,25 +242,26 @@ static int ReadSetting(const char *restrict const name)
|
|||||||
* /sbin/sysctl -a | egrep -6 dev.cdrom.info
|
* /sbin/sysctl -a | egrep -6 dev.cdrom.info
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
if (NameOnly) {
|
char *nlptr;
|
||||||
fprintf(stdout, "%s\n", outname);
|
|
||||||
} else {
|
|
||||||
/* already has the \n in it */
|
|
||||||
if (PrintName) {
|
if (PrintName) {
|
||||||
fprintf(stdout, "%s = %s",
|
fprintf(stdout, "%s = ", outname);
|
||||||
outname, inbuf);
|
do {
|
||||||
if (inbuf[strlen(inbuf) - 1] != '\n')
|
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');
|
putchar('\n');
|
||||||
} else {
|
} else {
|
||||||
if (!PrintNewline) {
|
if (!PrintNewline) {
|
||||||
char *nlptr =
|
nlptr = strchr(inbuf, '\n');
|
||||||
strchr(inbuf, '\n');
|
|
||||||
if (nlptr)
|
if (nlptr)
|
||||||
*nlptr = '\0';
|
*nlptr = '\0';
|
||||||
}
|
}
|
||||||
fprintf(stdout, "%s", inbuf);
|
fprintf(stdout, "%s", inbuf);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} while (fgets(inbuf, sizeof inbuf - 1, fp));
|
} while (fgets(inbuf, sizeof inbuf - 1, fp));
|
||||||
} else {
|
} else {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
|
Loading…
Reference in New Issue
Block a user