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

Cellular: fix calls to ATHandler::read_string(...) give correct size #10465

Merged
merged 1 commit into from
May 3, 2019

Conversation

jarvte
Copy link
Contributor

@jarvte jarvte commented Apr 24, 2019

Description

ATHandler::read_string(...) buffer size param was changed a long time ago to include also NULL. Some calls still gave wrong size after this change.

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

@AriParkkila @mirelachirica

Release Notes

@@ -396,7 +396,7 @@ bool AT_CellularContext::get_context()
char pdp_type_from_context[10];
int pdp_type_len = _at.read_string(pdp_type_from_context, sizeof(pdp_type_from_context) - 1);
if (pdp_type_len > 0) {
apn_len = _at.read_string(apn, sizeof(apn) - 1);
apn_len = _at.read_string(apn, sizeof(apn));

Choose a reason for hiding this comment

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

Fix sizeof(pdp_type_from_context) two lines above as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, fixed.

if (len > 0) {
imsi[len] = '\0';
}
_at.read_string(imsi, MAX_IMSI_LENGTH + 1);

Choose a reason for hiding this comment

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

Fix _at.read_string(buf, buf_size - 1); at AT_CellularInformation::get_info too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, fixed.

ATHandler::read_string(...) buffer size param was changed a long time ago
to include also NULL. Some calls still gave wrong size after this change.
@ciarmcom ciarmcom requested review from AriParkkila, mirelachirica and a team April 25, 2019 11:07
@ciarmcom
Copy link
Member

@jarvte, thank you for your changes.
@AriParkkila @mirelachirica @ARMmbed/mbed-os-wan @ARMmbed/mbed-os-maintainers please review.

@0xc0170
Copy link
Contributor

0xc0170 commented May 2, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented May 2, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

@0xc0170 0xc0170 merged commit 13880dc into ARMmbed:master May 3, 2019
@jarvte jarvte deleted the fix_imsi_length branch May 6, 2019 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants