Bug 229719 - src/lib/libpam/modules/pam_krb5/pam_krb5.c:536]: (style) Suspicious condition
Summary: src/lib/libpam/modules/pam_krb5/pam_krb5.c:536]: (style) Suspicious condition
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-12 10:43 UTC by David Binderman
Modified: 2023-09-07 17:31 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2018-07-12 10:43:11 UTC
src/lib/libpam/modules/pam_krb5/pam_krb5.c:536]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.

Source code is

        while ((krbret = krb5_cc_next_cred(pam_context, ccache_temp,
                                &cursor, &creds) == 0)) {

Maybe better code

        while ((krbret = krb5_cc_next_cred(pam_context, ccache_temp,
                                &cursor, &creds)) == 0) {
Comment 1 commit-hook freebsd_committer freebsd_triage 2023-08-04 16:09:27 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=acc7cf8641dcedad295ff0e569c3f3a28939ada0

commit acc7cf8641dcedad295ff0e569c3f3a28939ada0
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2023-08-04 16:08:21 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2023-08-04 16:08:37 +0000

    pam_krb5: Clarify a loop condition.

    The closing parenthesis was in the wrong location, so instead of assigning the return value to krbret and then comparing it to zero, we were assigning the result of the comparison to krbret and then comparing that to zero.  This has no practical significance since the value is not used after the loop terminates.

    PR:             229719
    Reviewed by:    cy
    Differential Revision:  https://reviews.freebsd.org/D41299

 lib/libpam/modules/pam_krb5/pam_krb5.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-09-07 17:31:40 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=27968aa02206baf85314305116fd63d55a3bebf4

commit 27968aa02206baf85314305116fd63d55a3bebf4
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2023-08-04 16:08:21 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2023-09-07 17:27:55 +0000

    pam_krb5: Clarify a loop condition.

    The closing parenthesis was in the wrong location, so instead of assigning the return value to krbret and then comparing it to zero, we were assigning the result of the comparison to krbret and then comparing that to zero.  This has no practical significance since the value is not used after the loop terminates.

    PR:             229719
    Reviewed by:    cy
    Differential Revision:  https://reviews.freebsd.org/D41299

    (cherry picked from commit acc7cf8641dcedad295ff0e569c3f3a28939ada0)

    pam_krb5: Rename a variable.

    Reviewed by:    cy
    Differential Revision:  https://reviews.freebsd.org/D41300

    (cherry picked from commit 9c2823bae92c09e5356623118da2777bc3ed521d)

 lib/libpam/modules/pam_krb5/pam_krb5.c | 181 ++++++++++++++++-----------------
 1 file changed, 90 insertions(+), 91 deletions(-)