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

discovery: allow to ignore resource in batch notification #623

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

Danielius1922
Copy link
Member

@Danielius1922 Danielius1922 commented Apr 19, 2024

Use OC_IGNORE response code to ignore resource in batch notification.

Summary by CodeRabbit

  • New Features

    • Enhanced notification handling in the discovery process for more nuanced decision-making.
    • Added support for batch responses in secure endpoints.
    • Improved handling of ETags for resource discovery to skip processing under specific conditions.
    • Introduced dynamic resource management in tests, including handling for ignored resources.
  • Bug Fixes

    • Added error logging and response failure handling in server API functions to improve reliability and error tracking.
  • Tests

    • Expanded unit tests to cover new functionalities such as batch discovery and dynamic resource handling.

Copy link

coderabbitai bot commented Apr 19, 2024

Walkthrough

The updates across various API components focus on enhancing response handling, resource discovery, and testing frameworks. Key changes include improved decision-making in response processing, support checks for batch responses, and extended testing capabilities with new classes and methods for dynamic resources and batch discovery scenarios. These changes aim to refine functionality and expand testing coverage for more robust software behavior.

Changes

File Path Change Summary
api/oc_discovery.c Revised logic in discovery_process_batch_response to include detailed checks for response codes and payload conditions.
api/oc_discovery_internal.h Added oc_discovery_batch_response_is_supported to verify batch response support with secure endpoints.
api/oc_ri.c Added conditional check in ri_invoke_coap_set_etag to skip ETag processing for certain batch requests.
api/oc_server_api.c Enhanced error handling in oc_send_response_internal and added fail-safe return in oc_send_response_with_callback.
api/unittest/.../discovery.cpp Introduced methods for handling ignored dynamic resources and added new dynamic resource "Dynamic Resource 4".
api/unittest/.../discoverytest.cpp Updated to include new headers, introduced TestBatchDiscoveryWithServer class, and revised test logic for batch requests and ETag handling.
api/unittest/.../discovery.h Updated function signatures and added new URIs and handler for ignored dynamic resources.
api/unittest/.../discoveryobservetest.cpp Renamed and added test cases to extend logic for observing changes in batch scenarios.
api/unittest/.../resourcetest.cpp Added handling and testing for a new ignored dynamic resource, including a new URI and test case.

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 603de5a and 1005f48.
Files selected for processing (9)
  • api/oc_discovery.c (9 hunks)
  • api/oc_discovery_internal.h (1 hunks)
  • api/oc_ri.c (2 hunks)
  • api/oc_server_api.c (2 hunks)
  • api/unittest/discovery/discovery.cpp (8 hunks)
  • api/unittest/discovery/discovery.h (2 hunks)
  • api/unittest/discovery/discoveryobservetest.cpp (2 hunks)
  • api/unittest/discovery/discoverytest.cpp (9 hunks)
  • api/unittest/resourcetest.cpp (7 hunks)
Files skipped from review as they are similar to previous changes (6)
  • api/oc_discovery_internal.h
  • api/unittest/discovery/discovery.cpp
  • api/unittest/discovery/discovery.h
  • api/unittest/discovery/discoveryobservetest.cpp
  • api/unittest/discovery/discoverytest.cpp
  • api/unittest/resourcetest.cpp
Additional Context Used
AST-based Instructions (15)
api/oc_discovery.c (5)

[warning] 758-758: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&rest_request, 0, sizeof(oc_request_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 760-760: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response, 0, sizeof(oc_response_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 762-762: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response_buffer, 0, sizeof(oc_response_buffer_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1259-1259: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&uri, 0, sizeof(oc_string_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1356-1356: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&result, 0, sizeof(result));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

api/oc_ri.c (7)

[warning] 773-773: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(aux_arr, 0, sizeof(aux_arr));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 831-831: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&handler, 0, sizeof(oc_request_handler_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1247-1247: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&result, 0, sizeof(result));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1697-1697: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(preparsed_request_obj, 0, sizeof(oc_ri_preparsed_request_obj_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1752-1752: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response_buffer, 0, sizeof(response_buffer));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1756-1756: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response_obj, 0, sizeof(response_obj));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1760-1760: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&request_obj, 0, sizeof(request_obj));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

api/oc_server_api.c (3)

[warning] 74-74: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&cfg.ports, 0, sizeof(cfg.ports));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 341-341: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&resource->name, 0, sizeof(oc_string_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 347-347: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&resource->types, 0, sizeof(oc_string_array_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

Additional comments not posted (3)
api/oc_server_api.c (2)

142-142: The addition of the error log for invalid response codes enhances error handling and debugging capabilities.


194-194: Adding a return statement to handle failures in sending responses is a good practice for robust error handling.

api/oc_ri.c (1)

1658-1665: Consider refining the conditional check for batch support.

The current implementation checks if the batch interface is secure before deciding to skip ETag processing. It might be beneficial to ensure that this logic is robust and handles all potential edge cases. Consider adding more detailed logging or error handling to provide clearer feedback on why certain requests are skipped.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ocf-conformance-test-tool
Copy link

🎉 Thank you for your code contribution! To guarantee the change/addition is conformant to the OCF Specification, we would like to ask you to execute OCF Conformance Testing of your change ☝️ when your work is ready to be reviewed.


ℹ️ To verify your latest change (cccfd14), label this PR with OCF Conformance Testing.

⚠️ Label is removed with every code change.

@Danielius1922 Danielius1922 marked this pull request as ready for review April 19, 2024 18:09
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Actionable comments outside the diff hunks (3)
api/oc_discovery.c (3)

Line range hint 728-732: Replace memset with memset_s to enhance security.

The use of memset for clearing structures like oc_request_t, oc_response_t, and oc_response_buffer_t can potentially lead to buffer overflows. Replace these with memset_s which is safer as it considers buffer boundaries.

- memset(&rest_request, 0, sizeof(oc_request_t));
- memset(&response, 0, sizeof(oc_response_t));
- memset(&response_buffer, 0, sizeof(oc_response_buffer_t));
+ memset_s(&rest_request, sizeof(oc_request_t), 0, sizeof(oc_request_t));
+ memset_s(&response, sizeof(oc_response_t), 0, sizeof(oc_response_t));
+ memset_s(&response_buffer, sizeof(oc_response_buffer_t), 0, sizeof(oc_response_buffer_t));

Line range hint 1242-1242: Replace memset with memset_s to prevent potential buffer overflows.

The use of memset to clear the oc_string_t structure can lead to buffer overflows. Use memset_s instead for enhanced safety.

- memset(&uri, 0, sizeof(oc_string_t));
+ memset_s(&uri, sizeof(oc_string_t), 0, sizeof(oc_string_t));

Line range hint 1339-1339: Replace memset with memset_s to ensure buffer safety.

The use of memset to clear the oc_rep_parse_result_t structure can lead to buffer overflows. Replace it with memset_s to ensure buffer boundaries are respected.

- memset(&result, 0, sizeof(result));
+ memset_s(&result, sizeof(result), 0, sizeof(result));

@Danielius1922 Danielius1922 force-pushed the adam/feature/ignore-resource-in-batch branch from cccfd14 to 5ce7882 Compare April 19, 2024 18:34
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Actionable comments outside the diff hunks (1)
api/oc_discovery.c (1)

Line range hint 758-762: Replace memset with memset_s to ensure buffer safety.

-  memset(&rest_request, 0, sizeof(oc_request_t));
-  memset(&response, 0, sizeof(oc_response_t));
-  memset(&response_buffer, 0, sizeof(oc_response_buffer_t));
+  memset_s(&rest_request, sizeof(oc_request_t), 0, sizeof(oc_request_t));
+  memset_s(&response, sizeof(oc_response_t), 0, sizeof(oc_response_t));
+  memset_s(&response_buffer, sizeof(oc_response_buffer_t), 0, sizeof(oc_response_buffer_t));

Using memset_s instead of memset can help prevent potential buffer overflows and ensure that the memory clearing is not optimized away by the compiler, which can happen with memset in certain optimization levels.

api/oc_discovery.c Outdated Show resolved Hide resolved
@Danielius1922 Danielius1922 force-pushed the adam/feature/ignore-resource-in-batch branch from 5ce7882 to a211487 Compare April 22, 2024 11:21
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Actionable comments outside the diff hunks (5)
api/oc_server_api.c (3)

Line range hint 74-74: Replace memset with memset_s to enhance security by preventing potential buffer overflows.

- memset(&cfg.ports, 0, sizeof(cfg.ports));
+ memset_s(&cfg.ports, sizeof(cfg.ports), 0, sizeof(cfg.ports));

Line range hint 341-341: Replace memset with memset_s in the oc_populate_resource_object function to prevent potential buffer overflows.

- memset(&resource->name, 0, sizeof(oc_string_t));
+ memset_s(&resource->name, sizeof(oc_string_t), 0, sizeof(oc_string_t));

Line range hint 347-347: Replace memset with memset_s to secure the initialization of oc_string_array_t types.

- memset(&resource->types, 0, sizeof(oc_string_array_t));
+ memset_s(&resource->types, sizeof(oc_string_array_t), 0, sizeof(oc_string_array_t));
api/oc_discovery.c (2)

Line range hint 1251-1251: Replace memset with memset_s for the uri variable to enhance security.

-  memset(&uri, 0, sizeof(oc_string_t));
+  memset_s(&uri, sizeof(oc_string_t), 0, sizeof(oc_string_t));

This change ensures that the buffer boundaries are respected, reducing the risk of buffer overflow.


Line range hint 1348-1348: Use memset_s instead of memset to clear the result structure.

-  memset(&result, 0, sizeof(result));
+  memset_s(&result, sizeof(result), 0, sizeof(result));

This modification is recommended to prevent potential buffer overflow issues by considering the size of the buffer.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Actionable comments outside the diff hunks (7)
api/oc_ri.c (7)

Line range hint 773-773: Replace memset with memset_s to enhance security.

- memset(aux_arr, 0, sizeof(aux_arr));
+ memset_s(aux_arr, sizeof(aux_arr), 0, sizeof(aux_arr));

This change prevents potential buffer overflow issues by ensuring the buffer boundaries are respected.


Line range hint 831-831: Replace memset with memset_s to enhance security.

- memset(&handler, 0, sizeof(oc_request_handler_t));
+ memset_s(&handler, sizeof(oc_request_handler_t), 0, sizeof(oc_request_handler_t));

This change prevents potential buffer overflow issues by ensuring the buffer boundaries are respected.


Line range hint 1247-1247: Replace memset with memset_s to enhance security.

- memset(&result, 0, sizeof(result));
+ memset_s(&result, sizeof(result), 0, sizeof(result));

This change prevents potential buffer overflow issues by ensuring the buffer boundaries are respected.


Line range hint 1697-1697: Replace memset with memset_s to enhance security.

- memset(preparsed_request_obj, 0, sizeof(oc_ri_preparsed_request_obj_t));
+ memset_s(preparsed_request_obj, sizeof(oc_ri_preparsed_request_obj_t), 0, sizeof(oc_ri_preparsed_request_obj_t));

This change prevents potential buffer overflow issues by ensuring the buffer boundaries are respected.


Line range hint 1752-1752: Replace memset with memset_s to enhance security.

- memset(&response_buffer, 0, sizeof(response_buffer));
+ memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));

This change prevents potential buffer overflow issues by ensuring the buffer boundaries are respected.


Line range hint 1756-1756: Replace memset with memset_s to enhance security.

- memset(&response_obj, 0, sizeof(response_obj));
+ memset_s(&response_obj, sizeof(response_obj), 0, sizeof(response_obj));

This change prevents potential buffer overflow issues by ensuring the buffer boundaries are respected.


Line range hint 1760-1760: Replace memset with memset_s to enhance security.

- memset(&request_obj, 0, sizeof(request_obj));
+ memset_s(&request_obj, sizeof(request_obj), 0, sizeof(request_obj));

This change prevents potential buffer overflow issues by ensuring the buffer boundaries are respected.

@Danielius1922 Danielius1922 force-pushed the adam/feature/ignore-resource-in-batch branch from fbd4696 to 00e7195 Compare April 22, 2024 14:24
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Actionable comments outside the diff hunks (3)
api/oc_discovery.c (2)

Line range hint 1259-1259: Replace memset with memset_s to ensure buffer boundaries are respected.

-  memset(&uri, 0, sizeof(oc_string_t));
+  memset_s(&uri, sizeof(oc_string_t), 0, sizeof(oc_string_t));

Using memset_s helps prevent potential buffer overflow issues by ensuring that the size of the buffer is considered during the operation.


Line range hint 1356-1356: Replace memset with memset_s to ensure buffer boundaries are respected.

-  memset(&result, 0, sizeof(result));
+  memset_s(&result, sizeof(result), 0, sizeof(result));

Using memset_s helps prevent potential buffer overflow issues by ensuring that the size of the buffer is considered during the operation.

api/oc_ri.c (1)

Line range hint 773-773: Replace memset with memset_s to enhance security.

- memset(aux_arr, 0, sizeof(aux_arr));
+ memset_s(aux_arr, sizeof(aux_arr), 0, sizeof(aux_arr));

- memset(&handler, 0, sizeof(oc_request_handler_t));
+ memset_s(&handler, sizeof(oc_request_handler_t), 0, sizeof(oc_request_handler_t));

- memset(&result, 0, sizeof(result));
+ memset_s(&result, sizeof(result), 0, sizeof(result));

- memset(preparsed_request_obj, 0, sizeof(oc_ri_preparsed_request_obj_t));
+ memset_s(preparsed_request_obj, sizeof(oc_ri_preparsed_request_obj_t), 0, sizeof(oc_ri_preparsed_request_obj_t));

- memset(&response_buffer, 0, sizeof(response_buffer));
+ memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));

- memset(&response_obj, 0, sizeof(response_obj));
+ memset_s(&response_obj, sizeof(response_obj), 0, sizeof(response_obj));

- memset(&request_obj, 0, sizeof(request_obj));
+ memset_s(&request_obj, sizeof(request_obj), 0, sizeof(request_obj));

Consider replacing memset with memset_s in the specified lines to prevent potential buffer overflow issues and enhance the security of the code.

Also applies to: 831-831, 1247-1247, 1697-1697, 1752-1752, 1756-1756, 1760-1760

Use OC_IGNORE response code to ignore resource in batch responses
or notifications.
@Danielius1922 Danielius1922 force-pushed the adam/feature/ignore-resource-in-batch branch from 00e7195 to 1005f48 Compare April 22, 2024 15:25
@Danielius1922 Danielius1922 requested a review from jkralik April 22, 2024 15:29
@Danielius1922 Danielius1922 added the OCF Conformance Testing OCF Conformance Testing required label Apr 22, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Actionable comments outside the diff hunks (12)
api/oc_server_api.c (3)

Line range hint 74-74: Consider replacing memset with memset_s to ensure safe operations that respect buffer boundaries.

- memset(&cfg.ports, 0, sizeof(cfg.ports));
+ memset_s(&cfg.ports, sizeof(cfg.ports), 0, sizeof(cfg.ports));

Line range hint 341-341: Consider replacing memset with memset_s to ensure safe operations that respect buffer boundaries.

- memset(&resource->name, 0, sizeof(oc_string_t));
+ memset_s(&resource->name, sizeof(oc_string_t), 0, sizeof(oc_string_t));

Line range hint 347-347: Consider replacing memset with memset_s to ensure safe operations that respect buffer boundaries.

- memset(&resource->types, 0, sizeof(oc_string_array_t));
+ memset_s(&resource->types, sizeof(oc_string_array_t), 0, sizeof(oc_string_array_t));
api/oc_discovery.c (2)

Line range hint 1259-1259: Replace memset with memset_s to ensure buffer boundaries are respected.

-  memset(&uri, 0, sizeof(oc_string_t));
+  memset_s(&uri, sizeof(oc_string_t), 0, sizeof(oc_string_t));

Using memset_s helps prevent potential buffer overflow issues by ensuring that the size of the buffer is considered during the operation.


Line range hint 1356-1356: Replace memset with memset_s to ensure buffer boundaries are respected.

-  memset(&result, 0, sizeof(result));
+  memset_s(&result, sizeof(result), 0, sizeof(result));

Using memset_s helps prevent potential buffer overflow issues by ensuring that the size of the buffer is considered during the operation.

api/oc_ri.c (7)

Line range hint 773-773: Replace memset with memset_s to ensure buffer safety.

- memset(aux_arr, 0, sizeof(aux_arr));
+ memset_s(aux_arr, sizeof(aux_arr), 0, sizeof(aux_arr));

This change helps prevent potential buffer overflow issues by ensuring that the buffer boundaries are respected.


Line range hint 831-831: Replace memset with memset_s to ensure buffer safety.

- memset(&handler, 0, sizeof(oc_request_handler_t));
+ memset_s(&handler, sizeof(oc_request_handler_t), 0, sizeof(oc_request_handler_t));

This change helps prevent potential buffer overflow issues by ensuring that the buffer boundaries are respected.


Line range hint 1247-1247: Replace memset with memset_s to ensure buffer safety.

- memset(&result, 0, sizeof(result));
+ memset_s(&result, sizeof(result), 0, sizeof(result));

This change helps prevent potential buffer overflow issues by ensuring that the buffer boundaries are respected.


Line range hint 1697-1697: Replace memset with memset_s to ensure buffer safety.

- memset(preparsed_request_obj, 0, sizeof(oc_ri_preparsed_request_obj_t));
+ memset_s(preparsed_request_obj, sizeof(oc_ri_preparsed_request_obj_t), 0, sizeof(oc_ri_preparsed_request_obj_t));

This change helps prevent potential buffer overflow issues by ensuring that the buffer boundaries are respected.


Line range hint 1752-1752: Replace memset with memset_s to ensure buffer safety.

- memset(&response_buffer, 0, sizeof(response_buffer));
+ memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));

This change helps prevent potential buffer overflow issues by ensuring that the buffer boundaries are respected.


Line range hint 1756-1756: Replace memset with memset_s to ensure buffer safety.

- memset(&response_obj, 0, sizeof(response_obj));
+ memset_s(&response_obj, sizeof(response_obj), 0, sizeof(response_obj));

This change helps prevent potential buffer overflow issues by ensuring that the buffer boundaries are respected.


Line range hint 1760-1760: Replace memset with memset_s to ensure buffer safety.

- memset(&request_obj, 0, sizeof(request_obj));
+ memset_s(&request_obj, sizeof(request_obj), 0, sizeof(request_obj));

This change helps prevent potential buffer overflow issues by ensuring that the buffer boundaries are respected.

api/oc_discovery.c Show resolved Hide resolved
Copy link

@Danielius1922 Danielius1922 merged commit 4dd98e5 into master Apr 22, 2024
125 checks passed
@Danielius1922 Danielius1922 deleted the adam/feature/ignore-resource-in-batch branch April 22, 2024 21:03
@github-actions github-actions bot locked and limited conversation to collaborators Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
OCF Conformance Testing OCF Conformance Testing required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants