Add wrappers for getpwnam and getgrnam (#4419)

This commit is contained in:
Yunshu Ouyang 2020-09-07 10:30:09 +02:00 committed by GitHub
parent e036c4fa32
commit 1b7b334da7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -15,6 +15,8 @@
////////////////////////////////////////////////////////////////////////////////
#include <sys/socket.h>
#include <sys/types.h>
#include <grp.h>
#include <pwd.h>
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;
}