aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Green <andy.green@linaro.org>2012-10-19 14:07:48 +0800
committerAndy Green <andy.green@linaro.org>2012-10-19 14:07:48 +0800
commit22c3416e9f3fd16e105b783a51c1404a415d75d4 (patch)
treed840c22e0498d58fdfe051b672fe2eccaa2fa794
parentcf911ae7b4c9206423c67a3ec1acf29522e3ea8b (diff)
fix the race causing the buffer overwrite
Signed-off-by: Andy Green <andy.green@linaro.org>
-rw-r--r--aepd/websocket-protocol.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/aepd/websocket-protocol.c b/aepd/websocket-protocol.c
index eecd922..6f11049 100644
--- a/aepd/websocket-protocol.c
+++ b/aepd/websocket-protocol.c
@@ -130,6 +130,9 @@ callback_linaro_aepd(struct libwebsocket_context *context,
case LWS_CALLBACK_SERVER_WRITEABLE:
+ if (aepd_shared->chans < 0)
+ break;
+
gettimeofday(&tv, NULL);
ms10 = (tv.tv_sec * 10) + (tv.tv_usec / 100000);
@@ -155,6 +158,8 @@ callback_linaro_aepd(struct libwebsocket_context *context,
goto bad_caliper;
if (lseek(aepd_shared->fd_fifo_read, l, SEEK_SET) < 0)
fprintf(stderr, "seek %ld failed\n", l);
+ if (sizeof(sam) < (aepd_shared->chans * sizeof(double) * 3))
+ fprintf(stderr, "reading too much %d\n", aepd_shared->chans);
if (read(aepd_shared->fd_fifo_read, &sam[0],
aepd_shared->chans * sizeof(double) * 3) < 0)
fprintf(stderr, "fifo read %ld failed\n", l);
@@ -166,6 +171,8 @@ callback_linaro_aepd(struct libwebsocket_context *context,
goto bad_caliper;
if (lseek(aepd_shared->fd_fifo_read, l, SEEK_SET) < 0)
fprintf(stderr, "seek %ld failed\n", l);
+ if (sizeof(sam2) < (aepd_shared->chans * sizeof(double) * 3))
+ fprintf(stderr, "reading too much %d\n", aepd_shared->chans);
if (read(aepd_shared->fd_fifo_read, &sam2[0],
aepd_shared->chans * sizeof(double) * 3) < 0)
fprintf(stderr, "fifo read %ld fail\n", l);