Skip to content

Commit

Permalink
lib: modem_key_mgmt: fix duplicate deletion of last cred type
Browse files Browse the repository at this point in the history
Because of the ok\r\n in response from modem, the while loop iterates
an extra round with scanf not matching any arguments. As the sectag
matched the last credential is attempted deleted again and the function
return an error. This commit fixes the issue by only deleting the
credential in the modem if we match the sectag and credential type in
scanf.

Signed-off-by: Eivind Jølsgard <[email protected]>
  • Loading branch information
eivindj-nordic authored and rlubos committed Jan 8, 2025
1 parent 6e0cb3a commit 1803a80
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,10 @@ Modem libraries

* Fixed handling of ``%NCELLMEAS`` notification with status 2 (measurement interrupted) and no cells.

* :ref:`modem_key_mgmt` library:

* Fixed an issue with the :c:func:`modem_key_mgmt_clear` function where it returned ``-ENOENT`` when the credential was cleared.

Multiprotocol Service Layer libraries
-------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion lib/modem_key_mgmt/modem_key_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ int modem_key_mgmt_clear(nrf_sec_tag_t sec_tag)

while (token != NULL) {
err = sscanf(token, "%%CMNG: %u,%u,\"", &tag, &type);
if (tag == sec_tag) {
if (tag == sec_tag && err == 2) {
err = nrf_modem_at_printf("AT%%CMNG=3,%u,%u", sec_tag, type);
}
token = strtok(NULL, "\n");
Expand Down

0 comments on commit 1803a80

Please sign in to comment.