aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2019-09-10 15:44:30 +0200
committerGravatar Christian Hesse <mail@eworm.de>2019-09-10 15:44:30 +0200
commit26bade2280bd767a2d0a5df66f78462df64586be (patch)
tree13b857b64910cc7c47b9c6f910393629a3a7bc67
parenta22012812b5920b315a33eab034bdb3b7b746385 (diff)
downloadudp514-journal-26bade2280bd767a2d0a5df66f78462df64586be.tar.gz
udp514-journal-26bade2280bd767a2d0a5df66f78462df64586be.tar.zst
do not crash on missing space
-rw-r--r--udp514-journal.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/udp514-journal.c b/udp514-journal.c
index b73f992..9783db8 100644
--- a/udp514-journal.c
+++ b/udp514-journal.c
@@ -49,7 +49,9 @@ int main(int argc, char **argv) {
/* parse priority */
if ((match = strndup(buffer, BUFFER_SIZE)) != NULL) {
- *strchr(match, ' ') = 0;
+ char * space = strchr(match, ' ');
+ if (space != NULL)
+ *space = 0;
for (pri = prioritynames; pri->c_name && strstr(match, pri->c_name) == NULL; pri++);
free(match);
priority = pri->c_val;