diff options
author | Andy Green <andy.green@linaro.org> | 2012-10-19 08:14:15 +0800 |
---|---|---|
committer | Andy Green <andy.green@linaro.org> | 2012-10-19 08:14:15 +0800 |
commit | 2f7ac869f7d50d1c14cf61943abd9447aabbd039 (patch) | |
tree | 733f541e0afc9232ac141342db96014f925ab44e | |
parent | 11e80db556dfece23e313a327bb95cb4efbef869 (diff) |
skip most lws service if zero channels or caliper range bad
Aimed at this reported by Nicolas with no probe, but I was
unable to reproduce. Looked through callback_linaro_aepd
(it must be there because it's called into by lws_handle_POLLOUT_event)
and avoided executed meaningless code if channel count is zero or
caliper range is bad.
*** buffer overflow detected ***: /usr/local/bin/aepd - websockets server terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x5c)[0x7f056c31582c]
/lib/x86_64-linux-gnu/libc.so.6(+0x109700)[0x7f056c314700]
/lib/x86_64-linux-gnu/libc.so.6(__read_chk+0x22)[0x7f056c314bb2]
/usr/local/bin/aepd - websockets server[0x401c62]
/usr/local/lib/libwebsockets.so.0(lws_handle_POLLOUT_event+0x1e7)[0x7f056c80e827]
/usr/local/lib/libwebsockets.so.0(libwebsocket_service_fd+0x422)[0x7f056c8113b2]
/usr/local/lib/libwebsockets.so.0(libwebsocket_service+0x73)[0x7f056c8118d3]
/usr/local/bin/aepd - websockets server[0x401796]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7f056c22c76d]
/usr/local/bin/aepd - websockets server[0x4018a1]
Can't reproduce so unsure if that nailed it.
Reported-by: Nicolas Dechesne <n-dechesne@ti.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
-rw-r--r-- | aepd/websocket-protocol.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/aepd/websocket-protocol.c b/aepd/websocket-protocol.c index 68eeb73..c2d12a2 100644 --- a/aepd/websocket-protocol.c +++ b/aepd/websocket-protocol.c @@ -132,7 +132,7 @@ callback_linaro_aepd(struct libwebsocket_context *context, gettimeofday(&tv, NULL); ms10 = (tv.tv_sec * 10) + (tv.tv_usec / 100000); - if (ms10 != pss->ms10_last_caliper) { + if (ms10 != pss->ms10_last_caliper && pss->caliper_offset[0] >= 0 && aepd_shared->chans) { pss->ms10_last_caliper = ms10; l = pss->ringbuffer_tail - pss->caliper_offset[0]; @@ -175,7 +175,7 @@ callback_linaro_aepd(struct libwebsocket_context *context, goto send; } - if (pss->issue_timestamp) { + if (pss->issue_timestamp && aepd_shared->chans) { pss->issue_timestamp = 0; /* @@ -199,7 +199,7 @@ callback_linaro_aepd(struct libwebsocket_context *context, goto send; } - if (!pss->channels_sent_flag) { + if (!pss->channels_sent_flag && aepd_shared->chans) { /* signal it's a message with channel names */ *p++ = '='; @@ -234,7 +234,7 @@ callback_linaro_aepd(struct libwebsocket_context *context, * aggregate up to 'budget' results in one websocket message */ - if (!pss->seen_rate) + if (!pss->seen_rate || !aepd_shared->chans) return 0; while (budget--) { |