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

IoTHubDeviceClient_LL_UploadMultipleBlocksToBlob() segfaults. #2554

Closed
ASeidelt opened this issue Jan 8, 2024 · 4 comments
Closed

IoTHubDeviceClient_LL_UploadMultipleBlocksToBlob() segfaults. #2554

ASeidelt opened this issue Jan 8, 2024 · 4 comments
Assignees

Comments

@ASeidelt
Copy link

ASeidelt commented Jan 8, 2024

SDK Version (Please Give Commit SHA if Manually Compiling)

Version LTS_08_2023 aka 1.11.0

Describe the Bug

When running/compiling Azure IoT C SDK on an embedded system with newlib as C library, calling IoTHubDeviceClient_LL_UploadMultipleBlocksToBlob() segfaults.

The reason could be traced to the following locations:

When formatting the response in line

STRING_HANDLE response = STRING_construct_sprintf(RESPONSE_BODY_FORMAT,
STRING_construct_sprintf() is called with responseMessage == NULL.

Passing NULL to printf() is undefined behavior.

This is because

if (IoTHubClient_LL_UploadToBlob_NotifyCompletion(
passes NULL as the last parameter.

Suggested fix:

Either pass a meaningful message (uploadSucceeded ? "HTTP success" : "HTTP failure") or an empty string ("").

@ewertons
Copy link
Contributor

ewertons commented Jan 8, 2024

@ASeidelt , this is an excellent bug description! Thank you.
The fix is to use the following:

        STRING_HANDLE response = STRING_construct_sprintf(RESPONSE_BODY_FORMAT,
                                                    uploadCorrelationId,
                                                    isSuccess ? RESPONSE_BODY_SUCCESS_BOOLEAN_STRING : RESPONSE_BODY_ERROR_BOOLEAN_STRING,
                                                    responseCode,
                                                    responseMessage != NULL ? responseMessage : EMPTY_STRING);

A PR will be out soon with the fix.

@ewertons
Copy link
Contributor

ewertons commented Jan 9, 2024

Fixed. Thank you @ASeidelt .

@ewertons ewertons closed this as completed Jan 9, 2024
@ASeidelt
Copy link
Author

Thanks for the fast response/fix.

Will this also be fixed in the LTS_08_2023 branch? Will there be a V1.11.1?

@ericwolz
Copy link
Contributor

This fix will be in the next LTS release later this month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants