Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix EAGAIN check in smb2_read_data #343

Merged
merged 1 commit into from
May 29, 2024

Conversation

LoveMHz
Copy link
Contributor

@LoveMHz LoveMHz commented May 20, 2024

GNU defines EAGAIN and EWOULDBLOCK as the same value but notes both values should be checked for portability.

This resolves a Read from socket failed issue introduced when building with non-GNU environments that define EAGAIN and EWOULDBLOCK as separate, distinct values.

As noted in the GNU libc documentation under 2.2 Error Codes.

Portability Note: In many older Unix systems, this condition was indicated by EWOULDBLOCK, which was a distinct error code different from EAGAIN. To make your program portable, you should check for both codes and treat them the same.

This patch corrects the check in smb2_read_data that could fail under a read_more_data goto and a socket read that returns EWOULDBLOCK.

Similar checks already appear in the libsmb2 codebase.

if (errno == EAGAIN || errno == EWOULDBLOCK) {

GNU defines EAGAIN and EWOULDBLOCK as the same value but notes both values should be checked for portability.
@LoveMHz LoveMHz changed the title Fix EAGAIN/EWOULDBLOCK check in smb2_read_data Fix EAGAINcheck in smb2_read_data May 20, 2024
@LoveMHz LoveMHz changed the title Fix EAGAINcheck in smb2_read_data Fix EAGAIN check in smb2_read_data May 20, 2024
@Wolf3s
Copy link
Contributor

Wolf3s commented May 20, 2024

GNU defines EAGAIN and EWOULDBLOCK as the same value but notes both values should be checked for portability.

This resolves a Read from socket failed issue introduced when building with non-GNU environments that define EAGAIN and EWOULDBLOCK as separate, distinct values.

As noted in the GNU libc documentation under 2.2 Error Codes.

Portability Note: In many older Unix systems, this condition was indicated by EWOULDBLOCK, which was a distinct error code different from EAGAIN. To make your program portable, you should check for both codes and treat them the same.

This patch corrects the check in smb2_read_data that could fail under a read_more_data goto and a socket read that returns EWOULDBLOCK.

Similar checks already appear in the libsmb2 codebase.

if (errno == EAGAIN || errno == EWOULDBLOCK) {

GNU defines EAGAIN and EWOULDBLOCK as the same value but notes both values should be checked for portability.

This resolves a Read from socket failed issue introduced when building with non-GNU environments that define EAGAIN and EWOULDBLOCK as separate, distinct values.

As noted in the GNU libc documentation under 2.2 Error Codes.

Portability Note: In many older Unix systems, this condition was indicated by EWOULDBLOCK, which was a distinct error code different from EAGAIN. To make your program portable, you should check for both codes and treat them the same.

This patch corrects the check in smb2_read_data that could fail under a read_more_data goto and a socket read that returns EWOULDBLOCK.

Similar checks already appear in the libsmb2 codebase.

if (errno == EAGAIN || errno == EWOULDBLOCK) {

I noticed that when i was compiling on nintendo switch to test on some tests that i did, So it´s aprovable.

@sahlberg sahlberg merged commit 19933ba into sahlberg:master May 29, 2024
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants