add_new_errorpage(): fix segfault accessing global config
another fallout of the config refactoring finished by
2e02dce0c3.
apparently no one using the ErrorFile directive used git master
during the last months, as there have been no reports about this issue.
This commit is contained in:
parent
df9074db6e
commit
4847d8cdb3
@ -815,7 +815,7 @@ static HANDLE_FUNC (handle_errorfile)
|
|||||||
unsigned long int err = get_long_arg (line, &match[2]);
|
unsigned long int err = get_long_arg (line, &match[2]);
|
||||||
char *page = get_string_arg (line, &match[4]);
|
char *page = get_string_arg (line, &match[4]);
|
||||||
|
|
||||||
add_new_errorpage (page, err);
|
add_new_errorpage (conf, page, err);
|
||||||
safefree (page);
|
safefree (page);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,17 +37,18 @@
|
|||||||
#define ERRORNUM_BUFSIZE 8 /* this is more than required */
|
#define ERRORNUM_BUFSIZE 8 /* this is more than required */
|
||||||
#define ERRPAGES_BUCKETCOUNT 16
|
#define ERRPAGES_BUCKETCOUNT 16
|
||||||
|
|
||||||
int add_new_errorpage (char *filepath, unsigned int errornum)
|
int add_new_errorpage (struct config_s *conf, char *filepath,
|
||||||
|
unsigned int errornum)
|
||||||
{
|
{
|
||||||
char errornbuf[ERRORNUM_BUFSIZE];
|
char errornbuf[ERRORNUM_BUFSIZE];
|
||||||
|
|
||||||
config->errorpages = hashmap_create (ERRPAGES_BUCKETCOUNT);
|
conf->errorpages = hashmap_create (ERRPAGES_BUCKETCOUNT);
|
||||||
if (!config->errorpages)
|
if (!conf->errorpages)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
snprintf (errornbuf, ERRORNUM_BUFSIZE, "%u", errornum);
|
snprintf (errornbuf, ERRORNUM_BUFSIZE, "%u", errornum);
|
||||||
|
|
||||||
if (hashmap_insert (config->errorpages, errornbuf,
|
if (hashmap_insert (conf->errorpages, errornbuf,
|
||||||
filepath, strlen (filepath) + 1) < 0)
|
filepath, strlen (filepath) + 1) < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
|
|||||||
@ -23,8 +23,9 @@
|
|||||||
|
|
||||||
/* Forward declaration */
|
/* Forward declaration */
|
||||||
struct conn_s;
|
struct conn_s;
|
||||||
|
struct config_s;
|
||||||
|
|
||||||
extern int add_new_errorpage (char *filepath, unsigned int errornum);
|
extern int add_new_errorpage (struct config_s *, char *filepath, unsigned int errornum);
|
||||||
extern int send_http_error_message (struct conn_s *connptr);
|
extern int send_http_error_message (struct conn_s *connptr);
|
||||||
extern int indicate_http_error (struct conn_s *connptr, int number,
|
extern int indicate_http_error (struct conn_s *connptr, int number,
|
||||||
const char *message, ...);
|
const char *message, ...);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user