summaryrefslogtreecommitdiff
path: root/log
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2016-01-24 09:19:53 +0100
committerFelix Fietkau <nbd@openwrt.org>2016-01-24 09:19:53 +0100
commit31d66f2c3b2afbc9eaae4e2c22103d0f79e9503e (patch)
tree11f1a421f7f1afb83a06fb175e889e2b31fb244f /log
parentc086167a0154745c677f8730a336ea9cf7d71031 (diff)
downloadubox-31d66f2c3b2afbc9eaae4e2c22103d0f79e9503e.tar.gz
logread: ensure that the len < sizeof(struct blob_attr) check runs before trying to access the data
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'log')
-rw-r--r--log/logread.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/log/logread.c b/log/logread.c
index dcf3c08..83b74b1 100644
--- a/log/logread.c
+++ b/log/logread.c
@@ -208,14 +208,19 @@ static int usage(const char *prog)
static void logread_fd_data_cb(struct ustream *s, int bytes)
{
while (true) {
- int len;
struct blob_attr *a;
+ int len, cur_len;
a = (void*) ustream_get_read_buf(s, &len);
- if (len < sizeof(*a) || len < blob_len(a) + sizeof(*a))
+ if (len < sizeof(*a))
break;
+
+ cur_len = blob_len(a) + sizeof(*a);
+ if (len < cur_len)
+ break;
+
log_notify(a);
- ustream_consume(s, blob_len(a) + sizeof(*a));
+ ustream_consume(s, cur_len);
}
if (!log_follow)
uloop_end();