-const char jcc_rcs[] = "$Id: jcc.c,v 1.378 2012/03/10 11:08:10 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.381 2012/07/23 12:40:52 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
&& (!strcmpic(http->ver, "HTTP/1.1")))
{
freez(http->ver);
- http->ver = strdup("HTTP/1.0");
-
- if (http->ver == NULL)
- {
- log_error(LOG_LEVEL_FATAL, "Out of memory downgrading HTTP version");
- }
+ http->ver = strdup_or_die("HTTP/1.0");
}
/*
else
{
/* XXX: ocmd is a misleading name */
- http->ocmd = strdup(http->cmd);
- if (http->ocmd == NULL)
- {
- log_error(LOG_LEVEL_FATAL,
- "Out of memory copying rewritten HTTP request line");
- }
+ http->ocmd = strdup_or_die(http->cmd);
}
return err;
assert(NULL != http->host);
server_connection->sfd = sfd;
- server_connection->host = strdup(http->host);
- if (NULL == server_connection->host)
- {
- log_error(LOG_LEVEL_FATAL, "Out of memory saving socket.");
- }
+ server_connection->host = strdup_or_die(http->host);
server_connection->port = http->port;
assert(NULL != fwd);
server_connection->forwarder_type = fwd->type;
if (NULL != fwd->gateway_host)
{
- server_connection->gateway_host = strdup(fwd->gateway_host);
- if (NULL == server_connection->gateway_host)
- {
- log_error(LOG_LEVEL_FATAL, "Out of memory saving gateway_host.");
- }
+ server_connection->gateway_host = strdup_or_die(fwd->gateway_host);
}
else
{
if (NULL != fwd->forward_host)
{
- server_connection->forward_host = strdup(fwd->forward_host);
- if (NULL == server_connection->forward_host)
- {
- log_error(LOG_LEVEL_FATAL, "Out of memory saving forward_host.");
- }
+ server_connection->forward_host = strdup_or_die(fwd->forward_host);
}
else
{
/*
* Save a copy of the original request for logging
*/
- http->ocmd = strdup(http->cmd);
- if (http->ocmd == NULL)
- {
- log_error(LOG_LEVEL_FATAL,
- "Out of memory copying HTTP request line");
- }
+ http->ocmd = strdup_or_die(http->cmd);
enlist(csp->headers, http->cmd);
/* Append the previously read headers */
else if (strcmp(argv[argc_pos], "--pidfile") == 0)
{
if (++argc_pos == argc) usage(argv[0]);
- pidfile = strdup(argv[argc_pos]);
+ pidfile = strdup_or_die(argv[argc_pos]);
}
else if (strcmp(argv[argc_pos], "--user") == 0)
if (++argc_pos == argc) usage(argv[argc_pos]);
- user_arg = strdup(argv[argc_pos]);
- if (NULL == user_arg)
- {
- log_error(LOG_LEVEL_FATAL,
- "Out of memory splitting --user argument '%s'.", argv[argc_pos]);
- }
+ user_arg = strdup_or_die(argv[argc_pos]);
group_name = strchr(user_arg, '.');
if (NULL != group_name)
{
else if (strcmp(argv[argc_pos], "--pre-chroot-nslookup") == 0)
{
if (++argc_pos == argc) usage(argv[0]);
- pre_chroot_nslookup_to_load_resolver = strdup(argv[argc_pos]);
+ pre_chroot_nslookup_to_load_resolver = strdup_or_die(argv[argc_pos]);
}
else if (strcmp(argv[argc_pos], "--chroot") == 0)
exit(1);
}
+ basedir = strdup_or_die(cwd);
/* XXX: why + 5? */
abs_file_size = strlen(cwd) + strlen(configfile) + 5;
- basedir = strdup(cwd);
-
- if (NULL == basedir ||
- NULL == (abs_file = malloc(abs_file_size)))
- {
- perror("malloc failed");
- exit(1);
- }
+ abs_file = malloc_or_die(abs_file_size);
strlcpy(abs_file, basedir, abs_file_size);
strlcat(abs_file, "/", abs_file_size);
strlcat(abs_file, configfile, abs_file_size);
{
log_error(LOG_LEVEL_FATAL, "Cannot setgid(): Insufficient permissions.");
}
- if (NULL != grp)
+ if ((NULL != grp) && setgroups(1, &grp->gr_gid))
{
- if (setgroups(1, &grp->gr_gid))
- {
- log_error(LOG_LEVEL_FATAL, "setgroups() failed: %E");
- }
+ log_error(LOG_LEVEL_FATAL, "setgroups() failed: %E");
}
else if (initgroups(pw->pw_name, pw->pw_gid))
{