mirror of https://github.com/F-Stack/f-stack.git
Merge pull request #214 from chadwill/master
Nginx: fixbug, hijack `getpeername` and `getsockname`.
This commit is contained in:
commit
e850874db3
|
@ -121,6 +121,9 @@ static int (*real_ioctl)(int, int, void *);
|
||||||
|
|
||||||
static int (*real_gettimeofday)(struct timeval *tv, struct timezone *tz);
|
static int (*real_gettimeofday)(struct timeval *tv, struct timezone *tz);
|
||||||
|
|
||||||
|
static int (*real_getpeername)(int sockfd, struct sockaddr * name, socklen_t *namelen);
|
||||||
|
static int (*real_getsockname)(int s, struct sockaddr *name, socklen_t *namelen);
|
||||||
|
|
||||||
static __thread int inited;
|
static __thread int inited;
|
||||||
|
|
||||||
#define SYSCALL(func) \
|
#define SYSCALL(func) \
|
||||||
|
@ -269,6 +272,32 @@ connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
|
||||||
return SYSCALL(connect)(sockfd, addr, addrlen);
|
return SYSCALL(connect)(sockfd, addr, addrlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
getpeername(int sockfd, struct sockaddr * name,
|
||||||
|
socklen_t *namelen)
|
||||||
|
{
|
||||||
|
if(is_fstack_fd(sockfd)){
|
||||||
|
sockfd = restore_fstack_fd(sockfd);
|
||||||
|
return ff_getpeername(sockfd,
|
||||||
|
(struct linux_sockaddr *)name, namelen);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SYSCALL(getpeername)(sockfd, name, namelen);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
getsockname(int sockfd, struct sockaddr *name,
|
||||||
|
socklen_t *namelen)
|
||||||
|
{
|
||||||
|
if(is_fstack_fd(sockfd)){
|
||||||
|
sockfd = restore_fstack_fd(sockfd);
|
||||||
|
return ff_getsockname(sockfd,
|
||||||
|
(struct linux_sockaddr *)name, namelen);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SYSCALL(getsockname)(sockfd, name, namelen);
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
send(int sockfd, const void *buf, size_t len, int flags)
|
send(int sockfd, const void *buf, size_t len, int flags)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue