From 1b7b334da7823ace48e46020c6c2b814ea6a8bd8 Mon Sep 17 00:00:00 2001 From: Yunshu Ouyang <61579667+yooyoo9@users.noreply.github.com> Date: Mon, 7 Sep 2020 10:30:09 +0200 Subject: [PATCH] Add wrappers for getpwnam and getgrnam (#4419) --- projects/nginx/build.sh | 2 +- projects/nginx/fuzz/wrappers.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/projects/nginx/build.sh b/projects/nginx/build.sh index 064a91739..341b0e5ac 100644 --- a/projects/nginx/build.sh +++ b/projects/nginx/build.sh @@ -24,7 +24,7 @@ rm -rf genfiles && mkdir genfiles && $SRC/LPM/external.protobuf/bin/protoc http_ cd ../.. auto/configure \ - --with-ld-opt="-Wl,--wrap=listen -Wl,--wrap=setsockopt -Wl,--wrap=bind -Wl,--wrap=shutdown -Wl,--wrap=connect" \ + --with-ld-opt="-Wl,--wrap=listen -Wl,--wrap=setsockopt -Wl,--wrap=bind -Wl,--wrap=shutdown -Wl,--wrap=connect -Wl,--wrap=getpwnam -Wl,--wrap=getgrnam" \ --with-http_v2_module make -f objs/Makefile fuzzers diff --git a/projects/nginx/fuzz/wrappers.c b/projects/nginx/fuzz/wrappers.c index ec8e3b7db..a351c37a3 100644 --- a/projects/nginx/fuzz/wrappers.c +++ b/projects/nginx/fuzz/wrappers.c @@ -15,6 +15,8 @@ //////////////////////////////////////////////////////////////////////////////// #include #include +#include +#include int __wrap_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { return 0; @@ -32,3 +34,15 @@ int __wrap_setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen) { return 0; } + +struct passwd *__wrap_getpwnam(const char *name){ + struct passwd *pwd = (struct passwd *) calloc(1, sizeof(struct passwd)); + 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; +}