X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fubox.git;a=blobdiff_plain;f=log%2Flogread.c;h=06dda62543928f71bbe918fc5a2a64dec0f7bcb2;hp=871cd5bffe9a855209a45e50f4ccad20dd0dadec;hb=c0138bae8ed746e30f3d3a591e1615f2a705b1a5;hpb=dd338ce30b6158f3f6feda9f01a2f409a8a5832c diff --git a/log/logread.c b/log/logread.c index 871cd5b..06dda62 100644 --- a/log/logread.c +++ b/log/logread.c @@ -102,6 +102,7 @@ static int log_notify(struct blob_attr *msg) char *str; time_t t; char *c, *m; + int ret = 0; if (sender.fd < 0) return 0; @@ -138,16 +139,16 @@ static int log_notify(struct blob_attr *msg) snprintf(buf, sizeof(buf), "<%u>", p); strncat(buf, c + 4, 16); if (hostname) { - strncat(buf, hostname, sizeof(buf)); - strncat(buf, " ", sizeof(buf)); + strncat(buf, hostname, sizeof(buf) - strlen(buf) - 1); + strncat(buf, " ", sizeof(buf) - strlen(buf) - 1); } if (log_prefix) { - strncat(buf, log_prefix, sizeof(buf)); - strncat(buf, ": ", sizeof(buf)); + strncat(buf, log_prefix, sizeof(buf) - strlen(buf) - 1); + strncat(buf, ": ", sizeof(buf) - strlen(buf) - 1); } if (blobmsg_get_u32(tb[LOG_SOURCE]) == SOURCE_KLOG) - strncat(buf, "kernel: ", sizeof(buf)); - strncat(buf, m, sizeof(buf)); + strncat(buf, "kernel: ", sizeof(buf) - strlen(buf) - 1); + strncat(buf, m, sizeof(buf) - strlen(buf) - 1); if (log_udp) err = write(sender.fd, buf, strlen(buf)); else @@ -165,14 +166,14 @@ static int log_notify(struct blob_attr *msg) snprintf(buf, sizeof(buf), "%s %s.%s%s %s\n", c, getcodetext(LOG_FAC(p) << 3, facilitynames), getcodetext(LOG_PRI(p), prioritynames), (blobmsg_get_u32(tb[LOG_SOURCE])) ? ("") : (" kernel:"), m); - write(sender.fd, buf, strlen(buf)); + ret = write(sender.fd, buf, strlen(buf)); } free(str); if (log_type == LOG_FILE) fsync(sender.fd); - return 0; + return ret; } static int usage(const char *prog)