Logger forgot to NULL terminate strings from stdin.
This commit is contained in:
parent
58a408512b
commit
5e8b3ea19d
2
logger.c
2
logger.c
@ -130,6 +130,7 @@ extern int logger_main(int argc, char **argv)
|
|||||||
while ((c = getc(stdin)) != EOF && i < sizeof(buf)) {
|
while ((c = getc(stdin)) != EOF && i < sizeof(buf)) {
|
||||||
buf[i++] = c;
|
buf[i++] = c;
|
||||||
}
|
}
|
||||||
|
buf[i++] = '\0';
|
||||||
message = buf;
|
message = buf;
|
||||||
} else {
|
} else {
|
||||||
len = 1; /* for the '\0' */
|
len = 1; /* for the '\0' */
|
||||||
@ -147,7 +148,6 @@ extern int logger_main(int argc, char **argv)
|
|||||||
openlog(name, option, (pri | LOG_FACMASK));
|
openlog(name, option, (pri | LOG_FACMASK));
|
||||||
syslog(pri, "%s", message);
|
syslog(pri, "%s", message);
|
||||||
closelog();
|
closelog();
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +130,7 @@ extern int logger_main(int argc, char **argv)
|
|||||||
while ((c = getc(stdin)) != EOF && i < sizeof(buf)) {
|
while ((c = getc(stdin)) != EOF && i < sizeof(buf)) {
|
||||||
buf[i++] = c;
|
buf[i++] = c;
|
||||||
}
|
}
|
||||||
|
buf[i++] = '\0';
|
||||||
message = buf;
|
message = buf;
|
||||||
} else {
|
} else {
|
||||||
len = 1; /* for the '\0' */
|
len = 1; /* for the '\0' */
|
||||||
@ -147,7 +148,6 @@ extern int logger_main(int argc, char **argv)
|
|||||||
openlog(name, option, (pri | LOG_FACMASK));
|
openlog(name, option, (pri | LOG_FACMASK));
|
||||||
syslog(pri, "%s", message);
|
syslog(pri, "%s", message);
|
||||||
closelog();
|
closelog();
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user