Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/libcrun/net_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ move_network_device (const char *ifname, const char *newifname, int netns_fd, li
{
ret = setup_network_device_in_ns_helper (buffer, buffer_size, netns_fd, newifname, ips, err);
if (UNLIKELY (ret < 0))
_safe_exit (-ret);
_safe_exit (crun_error_get_errno (err));

_safe_exit (0);
}
Expand All @@ -483,8 +483,9 @@ move_network_device (const char *ifname, const char *newifname, int netns_fd, li
if (UNLIKELY (ret < 0))
return crun_make_error (err, errno, "waitpid for exec child pid");

if (wait_status != 0)
return -get_process_exit_status (wait_status);
ret = get_process_exit_status (wait_status);
if (ret > 0)
return crun_make_error (err, ret, "set up network device");
Comment on lines +487 to +488

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The check if (ret > 0) doesn't handle the case where get_process_exit_status returns a negative value (e.g., -1 if the child process status is unexpected). In such a scenario, the function would incorrectly return 0, indicating success. It's better to handle all non-zero return values from get_process_exit_status as errors.

  if (ret != 0)
    return crun_make_error (err, ret > 0 ? ret : EIO, "set up network device");


return 0;
}