From 4aee6d8db462262666619bcdd402291188128539 Mon Sep 17 00:00:00 2001 From: Michael Tuexen <tuexen@fh-muenster.de> Date: Thu, 2 Aug 2018 16:11:27 +0200 Subject: [PATCH] Fix the checking of the return value of the close() systemcall. Ensure that 0.00 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 +1.00 close(3) = -1 is handled correctly. --- gtests/net/packetdrill/run_system_call.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gtests/net/packetdrill/run_system_call.c b/gtests/net/packetdrill/run_system_call.c index a68be5ae..3bb73fc2 100644 --- a/gtests/net/packetdrill/run_system_call.c +++ b/gtests/net/packetdrill/run_system_call.c @@ -2758,7 +2758,8 @@ static int syscall_ioctl(struct state *state, struct syscall_spec *syscall, static int syscall_close(struct state *state, struct syscall_spec *syscall, struct expression_list *args, char **error) { - int live_fd, script_fd, result; + int live_fd, script_fd, result, status; + if (check_arg_count(args, 1, error)) return STATUS_ERR; if (s32_arg(args, 0, &script_fd, error)) @@ -2770,13 +2771,13 @@ static int syscall_close(struct state *state, struct syscall_spec *syscall, result = close(live_fd); - if (end_syscall(state, syscall, CHECK_EXACT, result, error)) - return STATUS_ERR; - - if (run_syscall_close(state, script_fd, live_fd, error)) - return STATUS_ERR; + status = end_syscall(state, syscall, CHECK_EXACT, result, error); + if (result == 0) { + if (run_syscall_close(state, script_fd, live_fd, error)) + status = STATUS_ERR; + } - return STATUS_OK; + return status; } static int syscall_shutdown(struct state *state, struct syscall_spec *syscall, -- GitLab