1
0

proj/intercept.c: Fix some obvious bugs

This commit is contained in:
2025-05-05 14:00:20 +02:00
parent 707ff23c9e
commit faac51bb7f

View File

@@ -1845,7 +1845,7 @@ pid_t sym(wait)(int *stat_loc) {
} }
const pid_t ret = __real_wait(stat_loc); const pid_t ret = __real_wait(stat_loc);
if (stat_loc != NULL) { if (stat_loc != NULL) {
msg("return %i; errno %s; stat=%i", ret, *stat_loc, strerrorname_np(errno)); msg("return %i; errno %s; stat=%i", ret, strerrorname_np(errno), *stat_loc);
} else { } else {
msg("return %i; errno %s", ret, strerrorname_np(errno)); msg("return %i; errno %s", ret, strerrorname_np(errno));
} }
@@ -1874,7 +1874,7 @@ pid_t sym(waitpid)(pid_t pid, int *stat_loc, int options) {
} }
const pid_t ret = __real_waitpid(pid, stat_loc, options); const pid_t ret = __real_waitpid(pid, stat_loc, options);
if (stat_loc != NULL) { if (stat_loc != NULL) {
msg("return %i; errno %s; stat=%i", ret, *stat_loc, strerrorname_np(errno)); msg("return %i; errno %s; stat=%i", ret, strerrorname_np(errno), *stat_loc);
} else { } else {
msg("return %i; errno %s", ret, strerrorname_np(errno)); msg("return %i; errno %s", ret, strerrorname_np(errno));
} }
@@ -1903,7 +1903,7 @@ int sym(execl)(const char *pathname, const char *arg, ...) {
strcat(arg_buf_ptr, "NULL"); strcat(arg_buf_ptr, "NULL");
break; break;
} }
arg_buf_ptr += msg_str(arg_buf, sizeof(arg_buf) - (arg_buf_ptr - arg_buf), arg_vec[i], 0); arg_buf_ptr += msg_str(arg_buf_ptr, sizeof(arg_buf) - (arg_buf_ptr - arg_buf), arg_vec[i], 0);
} }
msg("execl(%es, %es%s)" ret_str, pathname, arg, arg_buf, ret_data); msg("execl(%es, %es%s)" ret_str, pathname, arg, arg_buf, ret_data);
@@ -1944,7 +1944,7 @@ int sym(execlp)(const char *file, const char *arg, ...) {
strcat(arg_buf_ptr, "NULL"); strcat(arg_buf_ptr, "NULL");
break; break;
} }
arg_buf_ptr += msg_str(arg_buf, sizeof(arg_buf) - (arg_buf_ptr - arg_buf), arg_vec[i], 0); arg_buf_ptr += msg_str(arg_buf_ptr, sizeof(arg_buf) - (arg_buf_ptr - arg_buf), arg_vec[i], 0);
} }
msg("execlp(%es, %es%s)" ret_str, file, arg, arg_buf, ret_data); msg("execlp(%es, %es%s)" ret_str, file, arg, arg_buf, ret_data);
@@ -1990,7 +1990,7 @@ int sym(execle)(const char *pathname, const char *arg, ...) {
strcat(arg_buf_ptr, "NULL"); strcat(arg_buf_ptr, "NULL");
break; break;
} }
arg_buf_ptr += msg_str(arg_buf, sizeof(arg_buf) - (arg_buf_ptr - arg_buf), arg_vec[i], 0); arg_buf_ptr += msg_str(arg_buf_ptr, sizeof(arg_buf) - (arg_buf_ptr - arg_buf), arg_vec[i], 0);
} }
int len = 0; for (len = 0; envp[len] != NULL; len++) {} int len = 0; for (len = 0; envp[len] != NULL; len++) {}
@@ -2219,7 +2219,7 @@ int sym(bind)(int sockfd, const struct sockaddr *address, socklen_t address_len)
init(); init();
Dl_info info; Dl_info info;
if (!dladdr(ret_addr, &info) || !func_flags[func_idx_bind] || !lib_flags[lib_idx]) return __real_bind(sockfd, address, address_len); if (!dladdr(ret_addr, &info) || !func_flags[func_idx_bind] || !lib_flags[lib_idx]) return __real_bind(sockfd, address, address_len);
msg("socket(%i, %qa, %i)" ret_str, sockfd, address_len, address, address_len, ret_data); msg("bind(%i, %qa, %i)" ret_str, sockfd, address_len, address, address_len, ret_data);
if (mode >= 4) { if (mode >= 4) {
char msg_buf[BUFFER_SIZE]; char msg_buf[BUFFER_SIZE];
rcv(msg_buf, sizeof(msg_buf)); rcv(msg_buf, sizeof(msg_buf));