574a6ecd2c
lying around...
243 lines
6.3 KiB
Plaintext
243 lines
6.3 KiB
Plaintext
$OpenBSD: patch-jcc_c,v 1.4 2001/06/09 04:21:29 angelos Exp $
|
|
--- jcc.c.orig Fri Oct 30 22:58:47 1998
|
|
+++ jcc.c Sat Jun 9 00:16:47 2001
|
|
@@ -226,7 +226,7 @@ chat(struct client_state *csp)
|
|
}
|
|
|
|
if(http->cmd == NULL) {
|
|
- strcpy(buf, CHEADER);
|
|
+ strlcpy(buf, CHEADER, sizeof(buf));
|
|
write_socket(csp->cfd, buf, strlen(buf));
|
|
return;
|
|
}
|
|
@@ -369,12 +369,19 @@ chat(struct client_state *csp)
|
|
}
|
|
|
|
if(errno == EINVAL) {
|
|
- err = zalloc(strlen(CNXDOM) + strlen(http->host));
|
|
- sprintf(err, CNXDOM, http->host);
|
|
+ if ((err = zalloc(strlen(CNXDOM) + strlen(http->host))) == NULL) {
|
|
+ fprintf(stderr, "%s:%d zalloc failed\n", __FILE__, __LINE__);
|
|
+ exit(-1);
|
|
+ }
|
|
+ snprintf(err, (strlen(CNXDOM) + strlen(http->host)), CNXDOM, http->host);
|
|
+
|
|
} else {
|
|
eno = safe_strerror(errno);
|
|
- err = zalloc(strlen(CFAIL) + strlen(http->hostport) + strlen(eno));
|
|
- sprintf(err, CFAIL, http->hostport, eno);
|
|
+ if ((err = zalloc(strlen(CFAIL) + strlen(http->hostport) + strlen(eno))) == NULL) {
|
|
+ fprintf(stderr, "%s:%d zalloc failed\n", __FILE__, __LINE__);
|
|
+ exit(-1);
|
|
+ }
|
|
+ snprintf(err, (strlen(CFAIL) + strlen(http->hostport) + strlen(eno)), CFAIL, http->hostport, eno);
|
|
}
|
|
|
|
write_socket(csp->cfd, err, strlen(err));
|
|
@@ -406,8 +413,11 @@ chat(struct client_state *csp)
|
|
}
|
|
|
|
eno = safe_strerror(errno);
|
|
- err = zalloc(strlen(CFAIL) + strlen(http->hostport) + strlen(eno));
|
|
- sprintf(err, CFAIL, http->hostport, eno);
|
|
+ if ((err = zalloc(strlen(CFAIL) + strlen(http->hostport) + strlen(eno))) == NULL) {
|
|
+ fprintf(stderr, "%s:%d zalloc failed\n", __FILE__, __LINE__);
|
|
+ exit(-1);
|
|
+ }
|
|
+ snprintf(err,(strlen(CFAIL) + strlen(http->hostport)), CFAIL, http->hostport, eno);
|
|
write_socket(csp->cfd, err, strlen(err));
|
|
|
|
freez(err);
|
|
@@ -488,7 +498,7 @@ chat(struct client_state *csp)
|
|
fperror(logfp, "");
|
|
|
|
eno = safe_strerror(errno);
|
|
- sprintf(buf, CFAIL, http->hostport, eno);
|
|
+ snprintf(buf, sizeof(buf), CFAIL, http->hostport, eno);
|
|
freez(eno);
|
|
write_socket(csp->cfd, buf, strlen(buf));
|
|
return;
|
|
@@ -606,6 +616,14 @@ server_thread(void *data)
|
|
}
|
|
#endif
|
|
|
|
+void
|
|
+sigcatcher(int sigraised)
|
|
+{
|
|
+ if (sigraised == SIGCHLD) {
|
|
+ waitpid(-1, NULL, WNOHANG);
|
|
+ }
|
|
+}
|
|
+
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
@@ -661,7 +679,7 @@ main(int argc, char *argv[])
|
|
|
|
line_num++;
|
|
|
|
- strcpy(tmp, buf);
|
|
+ strlcpy(tmp, buf, sizeof(tmp));
|
|
|
|
if((p = strpbrk(tmp, "#\r\n"))) *p = '\0';
|
|
|
|
@@ -678,7 +696,7 @@ main(int argc, char *argv[])
|
|
|
|
while(*p && ((*p == ' ') || (*p == '\t'))) p++;
|
|
|
|
- strcpy(arg, p);
|
|
+ strlcpy(arg, p, sizeof(arg));
|
|
|
|
p = arg + strlen(arg) - 1;
|
|
|
|
@@ -692,98 +710,98 @@ main(int argc, char *argv[])
|
|
|
|
savearg(cmd, arg);
|
|
|
|
- if(strcmp(cmd, "trustfile") == 0) {
|
|
+ if(strncmp(cmd, "trustfile", sizeof(cmd)-1) == 0) {
|
|
trustfile = strdup(arg);
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "trust_info_url") == 0) {
|
|
+ if(strncmp(cmd, "trust_info_url", sizeof(cmd)-1) == 0) {
|
|
enlist(trust_info, arg);
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "debug") == 0) {
|
|
+ if(strncmp(cmd, "debug", sizeof(cmd)-1) == 0) {
|
|
debug |= atoi(arg);
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "add-forwarded-header") == 0) {
|
|
+ if(strncmp(cmd, "add-forwarded-header", sizeof(cmd)-1) == 0) {
|
|
add_forwarded = 1;
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "single-threaded") == 0) {
|
|
+ if(strncmp(cmd, "single-threaded", sizeof(cmd)-1) == 0) {
|
|
multi_threaded = 0;
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "suppress-vanilla-wafer") == 0) {
|
|
+ if(strncmp(cmd, "suppress-vanilla-wafer", sizeof(cmd)-1) == 0) {
|
|
suppress_vanilla_wafer = 1;
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "wafer") == 0) {
|
|
+ if(strncmp(cmd, "wafer", sizeof(cmd)-1) == 0) {
|
|
enlist(wafer_list, arg);
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "add-header") == 0) {
|
|
+ if(strncmp(cmd, "add-header", sizeof(cmd)-1) == 0) {
|
|
enlist(xtra_list, arg);
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "cookiefile") == 0) {
|
|
+ if(strncmp(cmd, "cookiefile", sizeof(cmd)-1) == 0) {
|
|
cookiefile = strdup(arg);
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "logfile") == 0) {
|
|
+ if(strncmp(cmd, "logfile", sizeof(cmd)-1) == 0) {
|
|
logfile = strdup(arg);
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "blockfile") == 0) {
|
|
+ if(strncmp(cmd, "blockfile", sizeof(cmd)-1) == 0) {
|
|
blockfile = strdup(arg);
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "jarfile") == 0) {
|
|
+ if(strncmp(cmd, "jarfile", sizeof(cmd)-1) == 0) {
|
|
jarfile = strdup(arg);
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "listen-address") == 0) {
|
|
+ if(strncmp(cmd, "listen-address", sizeof(cmd)-1) == 0) {
|
|
haddr = strdup(arg);
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "forwardfile") == 0) {
|
|
+ if(strncmp(cmd, "forwardfile", sizeof(cmd)-1) == 0) {
|
|
forwardfile = strdup(arg);
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "aclfile") == 0) {
|
|
+ if(strncmp(cmd, "aclfile", sizeof(cmd)-1) == 0) {
|
|
aclfile = strdup(arg);
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "user-agent") == 0) {
|
|
+ if(strncmp(cmd, "user-agent", sizeof(cmd)-1) == 0) {
|
|
uagent = strdup(arg);
|
|
continue;
|
|
}
|
|
|
|
- if((strcmp(cmd, "referrer") == 0)
|
|
- || (strcmp(cmd, "referer" ) == 0)) {
|
|
+ if((strncmp(cmd, "referrer", sizeof(cmd)-1) == 0)
|
|
+ || (strncmp(cmd, "referer", sizeof(cmd)-1) == 0)) {
|
|
referrer = strdup(arg);
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "from") == 0) {
|
|
+ if(strncmp(cmd, "from", sizeof(cmd)-1) == 0) {
|
|
from = strdup(arg);
|
|
continue;
|
|
}
|
|
|
|
- if(strcmp(cmd, "hide-console") == 0) {
|
|
+ if(strncmp(cmd, "hide-console", sizeof(cmd)-1) == 0) {
|
|
hideConsole = 1;
|
|
continue;
|
|
}
|
|
@@ -891,8 +909,12 @@ main(int argc, char *argv[])
|
|
|
|
#ifndef _WIN32
|
|
signal(SIGPIPE, SIG_IGN);
|
|
+#ifdef __OpenBSD__
|
|
+ signal(SIGCHLD, sigcatcher);
|
|
+#else
|
|
signal(SIGCHLD, SIG_IGN);
|
|
#endif
|
|
+#endif
|
|
|
|
#ifdef _WIN32
|
|
{
|
|
@@ -994,7 +1016,7 @@ main(int argc, char *argv[])
|
|
fprintf(logfp, "%s: can't fork: ", prog);
|
|
fperror(logfp, "");
|
|
|
|
- sprintf(buf , "%s: can't fork: errno = %d",
|
|
+ snprintf(buf , sizeof(buf),"%s: can't fork: errno = %d",
|
|
prog, errno);
|
|
|
|
write_socket(csp->cfd, buf, strlen(buf));
|
|
@@ -1043,7 +1065,7 @@ safe_strerror(int err)
|
|
#endif /* NOSTRERROR */
|
|
|
|
if(s == NULL) {
|
|
- sprintf(buf, "(errno = %d)", err);
|
|
+ snprintf(buf, sizeof(buf),"(errno = %d)", err);
|
|
s = buf;
|
|
}
|
|
|