Browse Source

api: fix possible issue on linux

pull/4/head
Tanguy Pruvot 7 years ago
parent
commit
5b1b77ba95
  1. 4
      api.cpp

4
api.cpp

@ -1252,7 +1252,7 @@ static void api()
char *wskey = NULL; char *wskey = NULL;
n = recv(c, &buf[0], SOCK_REC_BUFSZ, 0); n = recv(c, &buf[0], SOCK_REC_BUFSZ, 0);
fail = SOCKETFAIL(n); fail = SOCKETFAIL(n) || n < 0;
if (fail) if (fail)
buf[0] = '\0'; buf[0] = '\0';
else if (n > 0 && buf[n-1] == '\n') { else if (n > 0 && buf[n-1] == '\n') {
@ -1261,7 +1261,7 @@ static void api()
if (n > 0 && buf[n-1] == '\r') if (n > 0 && buf[n-1] == '\r')
buf[n-1] = '\0'; buf[n-1] = '\0';
} }
buf[n] = '\0'; else buf[n] = '\0';
//if (opt_debug && opt_protocol && n > 0) //if (opt_debug && opt_protocol && n > 0)
// applog(LOG_DEBUG, "API: recv command: (%d) '%s'+char(%x)", n, buf, buf[n-1]); // applog(LOG_DEBUG, "API: recv command: (%d) '%s'+char(%x)", n, buf, buf[n-1]);

Loading…
Cancel
Save