mirror of
https://github.com/sonertari/SSLproxy
synced 2024-11-02 15:40:19 +00:00
Return 0 with pid -1 if no process matches
This commit is contained in:
parent
8c21170cd3
commit
18aca24a2c
10
nat.c
10
nat.c
@ -135,7 +135,7 @@ nat_pf_lookup_proc(pid_t *result, struct sockaddr *dst_addr, UNUSED socklen_t *d
|
|||||||
int pid_count = proc_listallpids(NULL, 0);
|
int pid_count = proc_listallpids(NULL, 0);
|
||||||
pids = malloc(sizeof(pid_t) * pid_count);
|
pids = malloc(sizeof(pid_t) * pid_count);
|
||||||
if (!pids) {
|
if (!pids) {
|
||||||
goto out1;
|
goto errout1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_count = proc_listallpids(pids, sizeof(pid_t) * pid_count);
|
pid_count = proc_listallpids(pids, sizeof(pid_t) * pid_count);
|
||||||
@ -155,7 +155,7 @@ nat_pf_lookup_proc(pid_t *result, struct sockaddr *dst_addr, UNUSED socklen_t *d
|
|||||||
}
|
}
|
||||||
fds = malloc(PROC_PIDLISTFD_SIZE * fd_count);
|
fds = malloc(PROC_PIDLISTFD_SIZE * fd_count);
|
||||||
if (!fds) {
|
if (!fds) {
|
||||||
goto out2;
|
goto errout2;
|
||||||
}
|
}
|
||||||
fd_count = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, fds,
|
fd_count = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, fds,
|
||||||
sizeof(fds[0]) * fd_count);
|
sizeof(fds[0]) * fd_count);
|
||||||
@ -206,15 +206,15 @@ nat_pf_lookup_proc(pid_t *result, struct sockaddr *dst_addr, UNUSED socklen_t *d
|
|||||||
|
|
||||||
/* valid match */
|
/* valid match */
|
||||||
*result = pid;
|
*result = pid;
|
||||||
ret = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
free(fds);
|
free(fds);
|
||||||
out2:
|
errout2:
|
||||||
free(pids);
|
free(pids);
|
||||||
out1:
|
errout1:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user