Browse Source

Fix missing close() for invalid commands

nfactor-troky
Kano 13 years ago
parent
commit
89c221ad8a
  1. 9
      api.c

9
api.c

@ -288,13 +288,9 @@ void api()
} }
inet_ntop(AF_INET, &(cli.sin_addr), &(tmpaddr[0]), sizeof(tmpaddr)-1); inet_ntop(AF_INET, &(cli.sin_addr), &(tmpaddr[0]), sizeof(tmpaddr)-1);
if (strcmp(tmpaddr, addr) != 0) if (strcmp(tmpaddr, addr) == 0) {
close(c);
else {
n = read(c, &buf[0], BUFSIZ-1); n = read(c, &buf[0], BUFSIZ-1);
if (n < 0) if (n >= 0) {
close(c);
else {
buf[n] = '\0'; buf[n] = '\0';
params = strchr(buf, '|'); params = strchr(buf, '|');
if (params != NULL) if (params != NULL)
@ -310,6 +306,7 @@ void api()
} }
} }
} }
close(c);
} }
close(sock); close(sock);

Loading…
Cancel
Save