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

New covscan errors in 'passkey' code #6733

Closed
alexey-tikhonov opened this issue May 15, 2023 · 3 comments
Closed

New covscan errors in 'passkey' code #6733

alexey-tikhonov opened this issue May 15, 2023 · 3 comments
Assignees
Labels
Closed: Fixed Issue was closed as fixed. Future work passkey Issues and PRs related to 'passkey' feature

Comments

@alexey-tikhonov
Copy link
Member

Error: GCC_ANALYZER_WARNING (CWE-401):
sssd-2.9.0/src/krb5_plugin/common/utils.c:62:22: warning[-Wanalyzer-malloc-leak]: leak of 'strdup(*array_17(D) + _7)'
#   60|       }
#   61|   
#   62|->     for (i = 0; array[i] != NULL; i++) {
#   63|           copy[i] = strdup(array[i]);
#   64|           if (copy[i] == NULL) {

Error: GCC_ANALYZER_WARNING (CWE-401):
sssd-2.9.0/src/krb5_plugin/common/utils.c:62:22: warning[-Wanalyzer-malloc-leak]: leak of 'strdup(*array_18(D) + _8)'
#   60|       }
#   61|   
#   62|->     for (i = 0; array[i] != NULL; i++) {
#   63|           copy[i] = strdup(array[i]);
#   64|           if (copy[i] == NULL) {

Error: CLANG_WARNING:
sssd-2.9.0/src/krb5_plugin/passkey/passkey_utils.c:562:5: warning[unix.Malloc]: Potential leak of memory pointed to by 'data'
#  560|       }
#  561|   
#  562|->     json_decref(jroot);
#  563|       return message;
#  564|   }

Error: UNREACHABLE (CWE-561):
sssd-2.9.0/src/responder/pam/pamsrv_passkey.c:1039: unreachable: This code cannot be reached: "if (!pctx->passkey_auth) {
...".
# 1037|   #endif
# 1038|   
# 1039|->     if (!pctx->passkey_auth) {
# 1040|           return false;
# 1041|       }

CC @ikerexxe, @pbrezina, @justin-stephenson

@alexey-tikhonov alexey-tikhonov added passkey Issues and PRs related to 'passkey' feature Future work labels May 15, 2023
@ikerexxe
Copy link
Contributor

Error: GCC_ANALYZER_WARNING (CWE-401):
sssd-2.9.0/src/krb5_plugin/common/utils.c:62:22: warning[-Wanalyzer-malloc-leak]: leak of 'strdup(*array_17(D) + _7)'
#   60|       }
#   61|   
#   62|->     for (i = 0; array[i] != NULL; i++) {
#   63|           copy[i] = strdup(array[i]);
#   64|           if (copy[i] == NULL) {

Error: GCC_ANALYZER_WARNING (CWE-401):
sssd-2.9.0/src/krb5_plugin/common/utils.c:62:22: warning[-Wanalyzer-malloc-leak]: leak of 'strdup(*array_18(D) + _8)'
#   60|       }
#   61|   
#   62|->     for (i = 0; array[i] != NULL; i++) {
#   63|           copy[i] = strdup(array[i]);
#   64|           if (copy[i] == NULL) {

These two are false positives. If anything fails while allocating memory in the loop sss_string_array_free() is called. This function manages the freeing of each element of the array, and then the pointer to the whole array.

ikerexxe added a commit to ikerexxe/sssd that referenced this issue May 18, 2023
Fixes following covscan issues:
```
Error: CLANG_WARNING:
sssd-2.9.0/src/krb5_plugin/passkey/passkey_utils.c:562:5: warning[unix.Malloc]: Potential leak of memory pointed to by 'data'
 #  560|       }
 #  561|
 #  562|->     json_decref(jroot);
 #  563|       return message;
 #  564|   }

Error: UNREACHABLE (CWE-561):
sssd-2.9.0/src/responder/pam/pamsrv_passkey.c:1039: unreachable: This code cannot be reached: "if (!pctx->passkey_auth) {
...".
 # 1037|   #endif
 # 1038|
 # 1039|->     if (!pctx->passkey_auth) {
 # 1040|           return false;
 # 1041|       }
```

Resolves: SSSD#6733

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
ikerexxe added a commit to ikerexxe/sssd that referenced this issue May 18, 2023
Fixes following covscan issues:
```
Error: CLANG_WARNING:
sssd-2.9.0/src/krb5_plugin/passkey/passkey_utils.c:562:5: warning[unix.Malloc]: Potential leak of memory pointed to by 'data'
 #  560|       }
 #  561|
 #  562|->     json_decref(jroot);
 #  563|       return message;
 #  564|   }

Error: UNREACHABLE (CWE-561):
sssd-2.9.0/src/responder/pam/pamsrv_passkey.c:1039: unreachable: This code cannot be reached: "if (!pctx->passkey_auth) {
...".
 # 1037|   #endif
 # 1038|
 # 1039|->     if (!pctx->passkey_auth) {
 # 1040|           return false;
 # 1041|       }
```

Resolves: SSSD#6733

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
ikerexxe added a commit to ikerexxe/sssd that referenced this issue May 22, 2023
Fixes following covscan issues:
```
Error: CLANG_WARNING:
sssd-2.9.0/src/krb5_plugin/passkey/passkey_utils.c:562:5: warning[unix.Malloc]: Potential leak of memory pointed to by 'data'
 #  560|       }
 #  561|
 #  562|->     json_decref(jroot);
 #  563|       return message;
 #  564|   }

Error: UNREACHABLE (CWE-561):
sssd-2.9.0/src/responder/pam/pamsrv_passkey.c:1039: unreachable: This code cannot be reached: "if (!pctx->passkey_auth) {
...".
 # 1037|   #endif
 # 1038|
 # 1039|->     if (!pctx->passkey_auth) {
 # 1040|           return false;
 # 1041|       }
```

Resolves: SSSD#6733

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
ikerexxe added a commit to ikerexxe/sssd that referenced this issue May 29, 2023
Fixes following covscan issues:
```
Error: CLANG_WARNING:
sssd-2.9.0/src/krb5_plugin/passkey/passkey_utils.c:562:5: warning[unix.Malloc]: Potential leak of memory pointed to by 'data'
 #  560|       }
 #  561|
 #  562|->     json_decref(jroot);
 #  563|       return message;
 #  564|   }

Error: UNREACHABLE (CWE-561):
sssd-2.9.0/src/responder/pam/pamsrv_passkey.c:1039: unreachable: This code cannot be reached: "if (!pctx->passkey_auth) {
...".
 # 1037|   #endif
 # 1038|
 # 1039|->     if (!pctx->passkey_auth) {
 # 1040|           return false;
 # 1041|       }
```

Resolves: SSSD#6733

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
@pbrezina
Copy link
Member

pbrezina commented Jun 8, 2023

Pushed PR: #6737

  • master
    • 702f7c2 - passkey: rename function
    • 0588bd3 - passkey: fix two covscan issues

@pbrezina pbrezina added the Closed: Fixed Issue was closed as fixed. label Jun 8, 2023
ikerexxe added a commit to ikerexxe/sssd that referenced this issue Aug 14, 2023
Fixes following covscan issues:
```
Error: CLANG_WARNING:
sssd-2.9.0/src/krb5_plugin/passkey/passkey_utils.c:562:5: warning[unix.Malloc]: Potential leak of memory pointed to by 'data'
 #  560|       }
 #  561|
 #  562|->     json_decref(jroot);
 #  563|       return message;
 #  564|   }

Error: UNREACHABLE (CWE-561):
sssd-2.9.0/src/responder/pam/pamsrv_passkey.c:1039: unreachable: This code cannot be reached: "if (!pctx->passkey_auth) {
...".
 # 1037|   #endif
 # 1038|
 # 1039|->     if (!pctx->passkey_auth) {
 # 1040|           return false;
 # 1041|       }
```

Resolves: SSSD#6733

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>

Reviewed-by: Justin Stephenson <jstephen@redhat.com>
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
alexey-tikhonov pushed a commit that referenced this issue Aug 14, 2023
Fixes following covscan issues:
```
Error: CLANG_WARNING:
sssd-2.9.0/src/krb5_plugin/passkey/passkey_utils.c:562:5: warning[unix.Malloc]: Potential leak of memory pointed to by 'data'
 #  560|       }
 #  561|
 #  562|->     json_decref(jroot);
 #  563|       return message;
 #  564|   }

Error: UNREACHABLE (CWE-561):
sssd-2.9.0/src/responder/pam/pamsrv_passkey.c:1039: unreachable: This code cannot be reached: "if (!pctx->passkey_auth) {
...".
 # 1037|   #endif
 # 1038|
 # 1039|->     if (!pctx->passkey_auth) {
 # 1040|           return false;
 # 1041|       }
```

Resolves: #6733

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>

Reviewed-by: Justin Stephenson <jstephen@redhat.com>
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>

Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Justin Stephenson <jstephen@redhat.com>
@alexey-tikhonov
Copy link
Member Author

Pushed PR: #6876

  • sssd-2-9
    • aba98a4 - passkey: rename function
    • f79ce53 - passkey: fix two covscan issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed: Fixed Issue was closed as fixed. Future work passkey Issues and PRs related to 'passkey' feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants