aboutsummaryrefslogtreecommitdiffstats
path: root/src/psmq-pub.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/psmq-pub.c')
-rw-r--r--src/psmq-pub.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/psmq-pub.c b/src/psmq-pub.c
index 1eee94b..679a8f2 100644
--- a/src/psmq-pub.c
+++ b/src/psmq-pub.c
@@ -123,6 +123,7 @@ static void send_stdin
{
unsigned int topiclen; /* length of topic string */
unsigned int linemax; /* max allowed length of line buf */
+ unsigned int paylen; /* length of payload to send */
char line[PSMQ_MSG_MAX]; /* single line read from stdin */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
@@ -178,10 +179,12 @@ static void send_stdin
return;
}
- /* now we have full line in buffer, ship
- * it. -1 is just so publish don't send
- * newline character */
- if (publish(psmq, topic, line, strlen(line) - 1, prio) != 0)
+ /* now we have full line in buffer, ship it. */
+ paylen = strlen(line);
+ /* remove new line character from string */
+ line[paylen - 1] = '\0';
+ /* send valid string with null terminator */
+ if (publish(psmq, topic, line, paylen, prio) != 0)
return;
}
}