From 950c4ed9c6bb9c31d540c9f0aff436538fe3a045 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 23 Sep 2014 00:45:12 +0100 Subject: [PATCH] Check return value of fseek for errors. --- src/websockets.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/websockets.c b/src/websockets.c index 5c0741cc..676d527e 100644 --- a/src/websockets.c +++ b/src/websockets.c @@ -475,7 +475,11 @@ static int callback_http(struct libwebsocket_context *context, } wlen = libwebsocket_write(wsi, buf, buflen, LWS_WRITE_HTTP); if(wlen < buflen){ - fseek(u->fptr, buflen-wlen, SEEK_CUR); + if(fseek(u->fptr, buflen-wlen, SEEK_CUR) < 0){ + fclose(u->fptr); + u->fptr = NULL; + return -1; + } }else{ if(buflen < sizeof(buf)){ fclose(u->fptr);