Skip to content

Commit

Permalink
Use return value from socket_send instead of using errno
Browse files Browse the repository at this point in the history
  • Loading branch information
nikias committed Mar 27, 2024
1 parent 303ece5 commit 3d9f5df
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/libusbmuxd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1592,8 +1592,7 @@ int usbmuxd_send(int sfd, const char *data, uint32_t len, uint32_t *sent_bytes)
num_sent = socket_send(sfd, (void*)data, len);
if (num_sent < 0) {
*sent_bytes = 0;
num_sent = errno;
LIBUSBMUXD_DEBUG(1, "%s: Error %d when sending: %s\n", __func__, num_sent, strerror(num_sent));
LIBUSBMUXD_DEBUG(1, "%s: Error %d when sending: %s\n", __func__, -num_sent, strerror(-num_sent));
return -num_sent;
}

Expand Down

1 comment on commit 3d9f5df

@mexmer
Copy link

@mexmer mexmer commented on 3d9f5df Apr 2, 2024

Choose a reason for hiding this comment

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

@nikias
this fix is not valid, on contrary you broke usbmuxd_send completely.
socket_send function returns errno or wsasocketerror as negative value (i just checked in glue), but this will effectively change it to positive value, so this function will always return >= 0, and you will not get error (negative value).

Please sign in to comment.