struct sockaddr_in addr_i;
struct hostent *hp;
- int new_sock;
+ int new_sock = -1;
/*debug_set_mode(TRUE);*/
if (! Socket) {
}
memset(buf, '\0', sizeof(buf));
while ((n_read = read(sock, buf, BUFSIZ)) > 0) {
+ n_read = n_read < BUFSIZ ? n_read : BUFSIZ - 1;
+ buf[n_read] = '\0';
if (buf[strlen(buf) - 1] == '\n')
buf[strlen(buf) - 1] = '\0';
debug_print("Ping result: %s\n", buf);
}
memset(buf, '\0', sizeof(buf));
while ((n_read = read(sock, buf, sizeof(buf))) > 0) {
- buf[sizeof(buf) - 1] = '\0';
+ buf[n_read] = '\0';
if (buf[strlen(buf) - 1] == '\n')
buf[strlen(buf) - 1] = '\0';
debug_print("Version: %s\n", buf);
result->msg = g_strdup(tmp);
g_free(tmp);
debug_print("result: %s\n", result->msg);
- close(sock);
return stat;
}
debug_print("copy to buf: %s\n", tmp);
g_free(command);
memset(buf, '\0', sizeof(buf));
while ((n_read = read(sock, buf, BUFSIZ)) > 0) {
- buf[sizeof(buf) - 1] = '\0';
+ n_read = n_read < BUFSIZ ? n_read : BUFSIZ - 1;
+ buf[n_read] = '\0';
if (buf[strlen(buf) - 1] == '\n')
buf[strlen(buf) - 1] = '\0';
}