[nginx] Fix startup crashes (#4433)

* Fix startup crashes

* Clean-up fuzzer
This commit is contained in:
Yunshu Ouyang 2020-09-10 16:49:59 +02:00 committed by GitHub
parent 7033ab69e6
commit b0c1a12b03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 18 deletions

View File

@ -101,7 +101,7 @@ static char arg1[] = {0, 0xA, 0};
extern char **environ;
static const char *config_file = "http_config.conf";
static const char *config_file = "/tmp/http_config.conf";
struct fuzzing_data {
const uint8_t *data;
@ -307,15 +307,4 @@ DEFINE_PROTO_FUZZER(const HttpProto &input) {
// Will redirect to http parser
ngx_http_init_connection(c);
// Clean-up in case of error
if (req_reply && upstream && upstream->cleanup) {
(*(upstream->cleanup))(req_reply);
if (!c->destroyed)
ngx_http_close_connection(c);
} else if (!c->destroyed) {
ngx_http_request_t *r = (ngx_http_request_t *)(c->data);
ngx_http_free_request(r, 0);
ngx_http_close_connection(c);
}
}

View File

@ -44,14 +44,15 @@ int __wrap_chown(const char *pathname, uid_t owner, gid_t group){
return 0;
}
struct passwd pwd;
struct group grp;
struct passwd *__wrap_getpwnam(const char *name){
struct passwd *pwd = (struct passwd *) calloc(1, sizeof(struct passwd));
pwd->pw_uid = 1;
return pwd;
pwd.pw_uid = 1;
return &pwd;
}
struct group *__wrap_getgrnam(const char *name){
struct group *grp = (struct group *) calloc(1, sizeof(struct group));
grp->gr_gid = 1;
return grp;
grp.gr_gid = 1;
return &grp;
}