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

[Coverity CID :203528]Integer handling issues in /tests/lib/fdtable/src/main.c #18451

Closed
aasthagr opened this issue Aug 17, 2019 · 2 comments · Fixed by #21086
Closed

[Coverity CID :203528]Integer handling issues in /tests/lib/fdtable/src/main.c #18451

aasthagr opened this issue Aug 17, 2019 · 2 comments · Fixed by #21086
Assignees
Labels
area: Tests Issues related to a particular existing or missing test bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug

Comments

@aasthagr
Copy link
Collaborator

Static code scan issues seen in File: /tests/lib/fdtable/src/main.c
Category: Integer handling issues
Function: test_z_alloc_fd
Component: Tests
CID: 203528
Please fix or provide comments to square it off in coverity in the link: https://scan9.coverity.com/reports.htm#v32951/p12996

@aasthagr aasthagr added area: Tests Issues related to a particular existing or missing test bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix labels Aug 17, 2019
@galak galak added the priority: low Low impact/importance bug label Aug 18, 2019
@applejax124 applejax124 removed their assignment Oct 29, 2019
@aescolar
Copy link
Member

f1afb4c

 82void test_z_alloc_fd(void)
 83{
 84        const struct fd_op_vtable *vtable = NULL;
 85        int *obj = NULL;
 86
   	1. negative_return_fn: Function z_alloc_fd(obj, vtable) returns a negative number. [show details]
   	2. assign: Assigning: fd = z_alloc_fd(obj, vtable).
 87        int fd = z_alloc_fd(obj, vtable); /* function being tested */
 88
 89        obj = z_get_fd_obj_and_vtable(fd, &vtable);
 90
   	3. Condition (void *)obj == NULL, taking true branch.
   	4. Condition (void *)obj == NULL, taking true branch.
   	5. Condition "obj is different after allocating", taking true branch.
   	6. Condition "obj is different after allocating", taking true branch.
 91        zassert_equal_ptr(obj, NULL, "obj is different after allocating");
   	7. Condition (void *)vtable == NULL, taking true branch.
   	8. Condition (void *)vtable == NULL, taking true branch.
   	9. Condition "vtable is different after allocating", taking true branch.
   	10. Condition "vtable is different after allocating", taking true branch.
 92        zassert_equal_ptr(vtable, NULL, "vtable is different after allocating");
 93
   	
CID 203528 (#1 of 1): Improper use of negative value (NEGATIVE_RETURNS)
11. negative_returns: fd is passed to a parameter that cannot be negative. [show details]
 94        z_free_fd(fd);
 95}

@aescolar
Copy link
Member

aescolar commented Nov 11, 2019

@nashif Who takes this one?

nashif added a commit to nashif/zephyr that referenced this issue Nov 29, 2019
Check for negative file descriptor.

Fixes zephyrproject-rtos#18448
Fixes zephyrproject-rtos#18450
Fixes zephyrproject-rtos#18449
Fixes zephyrproject-rtos#18451

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
nashif added a commit that referenced this issue Dec 2, 2019
Check for negative file descriptor.

Fixes #18448
Fixes #18450
Fixes #18449
Fixes #18451

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Tests Issues related to a particular existing or missing test bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants