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

Potential issue in sdk/src/azure/iot/az_iot_hub_client_c2d.c: Return Value Not Checked from Function Call #1482

Closed
monocle-ai opened this issue Nov 6, 2020 · 0 comments · Fixed by #1490
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@monocle-ai
Copy link

In this codebase, you often check the return value of the implicated function when calling it, but in this instance, it appears that you didn’t. Using a consistent return value checking and/or error handling approach can improve code robustness and readability.

1 instance of this defect were found in the following locations:


Instance 1
File : sdk/src/azure/iot/az_iot_hub_client_c2d.c
Enclosing Function : az_iot_hub_client_c2d_parse_received_topic
Function : _az_span_token

_az_span_token(received_topic, c2d_topic_suffix, &remainder, &index);

Code extract:

  int32_t index = 0;
  az_span remainder;
  _az_span_token(received_topic, c2d_topic_suffix, &remainder, &index); <------ HERE
  if (index == -1)
  {

How can I fix it?
Correct reference usage found in sdk/src/azure/iot/az_iot_provisioning_client.c at line 545.

int_slice = _az_span_token(remainder, AZ_SPAN_FROM_STR("&"), &remainder, &index);

Code extract:

  if (idx != -1)
  {
    remainder = az_span_slice_to_end(remainder, idx + az_span_size(retry_after));
    int_slice = _az_span_token(remainder, AZ_SPAN_FROM_STR("&"), &remainder, &index); <------ HERE

    _az_RETURN_IF_FAILED(az_span_atou32(int_slice, &out_response->retry_after_seconds));
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Nov 6, 2020
ewertons added a commit to ewertons/azure-sdk-for-c that referenced this issue Nov 10, 2020
danewalton added a commit that referenced this issue Nov 16, 2020
* Make sure we always log in as app or provisioner (#1480)

This also adds previously-required parameters back into
@PSBoundParameters to pass down to pre- and post-scripts.

Co-authored-by: Heath Stewart <heaths@microsoft.com>

* update changelog for beta 2 (#1484)

* Sync eng/common directory with azure-sdk-tools for PR 1163 (#1483)

* Update subscription configuration schema to include new parameters

* Support platform specific arm template parameters and legacy hashtable format

* Update arm template parameter comment to include top level key

* Restore AdditionalParameters. Merge ArmTemplateParameters from stringified hash literal

* Handle duplicate keys more explicitly for arm and env vars

* Regenerate New-TestResources.ps1 markdown

* revert variable name to environmentVariables to fix post-scripts

* Handle empty arm template parameters better

* Remove arm template parameter merge logic from deploy template

* Add merge hashes function to New-TestResources.ps1

* Add merge hashes function to New-TestResources.ps1

* Add env variable overwrite warning. Use ContainsKey checks

* Temporarily manually fix invalid generated markdown links

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

* Sync eng/common directory with azure-sdk-tools for PR 1178 (#1487)

* Refactor eng/common/README.md

* Add doc directory

Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>

* Fix broken eng/common doc link (#1489)

Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>

* Explicitly ignore return of _az_span_token on c2d parsing (#1482) (#1490)

* add latest static analyzer fix to changelog (#1491)

* Sync eng/common directory with azure-sdk-tools for PR 1188 (#1502)

* Add debug flag to arm deployment command

* Only set debug preference when $CI is true

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

* Remove invalid characters in basename sourced from username (#1503)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

* Sync eng/common directory with azure-sdk-tools for PR 1170 (#1481)

* Added the preprocess scripts.

* string array to string

Co-authored-by: Sima Zhu <sizhu@microsoft.com>

* Reorganization of samples readme (#1505)

* Completion of Sample Readme update (#1508)

* Add Invoke-DevOpsAPI.ps1, Add functions for Canceling and Listing Builds (#1474)

Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>

* Change live test resource DeleteAfterHours tag to 8 hours (#1509)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

* adding notes about security on readme file (#1498)

* adding notes about security on readme file

* Update sdk/samples/iot/docs/how_to_iot_hub_esp8266_nodemcu.md

Co-authored-by: Mollie Munoz <mollie.munoz@microsoft.com>

* Update sdk/samples/iot/docs/how_to_iot_hub_esp8266_nodemcu.md

Co-authored-by: Ahson Khan <ahson_ahmedk@yahoo.com>

* Update sdk/samples/iot/docs/how_to_iot_hub_esp8266_nodemcu.md

Co-authored-by: Ahson Khan <ahson_ahmedk@yahoo.com>

* Update sdk/samples/iot/docs/how_to_iot_hub_esp8266_nodemcu.md

Co-authored-by: Mollie Munoz <mollie.munoz@microsoft.com>

* Update sdk/samples/iot/docs/how_to_iot_hub_esp8266_nodemcu.md

Co-authored-by: Ahson Khan <ahson_ahmedk@yahoo.com>

* Update sdk/samples/iot/docs/how_to_iot_hub_esp8266_nodemcu.md

Co-authored-by: Mollie Munoz <mollie.munoz@microsoft.com>

* Update how_to_iot_hub_esp8266_nodemcu.md

* Update sdk/samples/iot/docs/how_to_iot_hub_esp8266_nodemcu.md

Co-authored-by: Eric Wolz <ericwol@microsoft.com>

* Update sdk/samples/iot/docs/how_to_iot_hub_esp8266_nodemcu.md

Co-authored-by: Eric Wolz <ericwol@microsoft.com>

* Update sdk/samples/iot/docs/how_to_iot_hub_esp8266_nodemcu.md

Co-authored-by: Eric Wolz <ericwol@microsoft.com>

Co-authored-by: Mollie Munoz <mollie.munoz@microsoft.com>
Co-authored-by: Ahson Khan <ahson_ahmedk@yahoo.com>
Co-authored-by: Eric Wolz <ericwol@microsoft.com>

* Sync eng/common directory with azure-sdk-tools for PR 1202 (#1510)

* Add debugging link on resource deployment failures to log output

* Update aka link for live test help docs. Use here string and empty throw.

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

* Sync eng/common directory with azure-sdk-tools for PR 1153 (#1513)

* Improve Update-ChangeLog Logic

* Updates to ChangeLog-Operations.ps1, copy-docs-to-blobstorage.ps1, Invoke-GitHubAPI.ps1 and Package-Properties.ps1

* More changeLog Logic Improvements

* Update date parsing

Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>

* Revert "Places where we have const* arguments in source, optionally mark the value as const as well. (#1261)" (#1517)

This reverts commit 5723678.

* Update AddAzureSDKforC.cmake to reference the latest tagged release of the SDK (#1495)

* Update AddAzureSDKforC.cmake to reference the latest release of the SDK

* Remove pnp from the tag being referenced.

* Incrementing master CL and version to be above the next release from the feature branch (#1506)

* Update LanguageSetting.ps1 (#1518)

Co-authored-by: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com>
Co-authored-by: Heath Stewart <heaths@microsoft.com>
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
Co-authored-by: ewertons <ewertons@microsoft.com>
Co-authored-by: Sima Zhu <sizhu@microsoft.com>
Co-authored-by: Mollie Munoz <mollie.munoz@microsoft.com>
Co-authored-by: Wellington Duraes <wellington.duraes@gmail.com>
Co-authored-by: Ahson Khan <ahson_ahmedk@yahoo.com>
Co-authored-by: Eric Wolz <ericwol@microsoft.com>
Co-authored-by: Chidozie Ononiwu <31145988+chidozieononiwu@users.noreply.github.com>
@RickWinter RickWinter added Client This issue points to a problem in the data-plane of the library. and removed needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Dec 7, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Apr 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants