[Bug 2804] New: channels.c:3258: suspicious code ?

bugzilla-daemon at bugzilla.mindrot.org bugzilla-daemon at bugzilla.mindrot.org
Mon Dec 4 23:05:05 AEDT 2017


https://bugzilla.mindrot.org/show_bug.cgi?id=2804

            Bug ID: 2804
           Summary: channels.c:3258: suspicious code ?
           Product: Portable OpenSSH
           Version: 7.6p1
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P5
         Component: Miscellaneous
          Assignee: unassigned-bugs at mindrot.org
          Reporter: dcb314 at hotmail.com

channels.c:3258]: (warning) The comparison operator in
'strcmp(listen_addr,"localhost") != 0' should maybe be '==' instead,
currently the expression 'strcmp(listen_addr,"127.0.0.1") == 0' is
redundant.

Source code is

        } else if (strcmp(listen_addr, "localhost") != 0 ||
            strcmp(listen_addr, "127.0.0.1") == 0 ||
            strcmp(listen_addr, "::1") == 0) {
            /* Accept localhost address when GatewayPorts=yes */
            addr = listen_addr;
        }

Maybe better code

        } else if (strcmp(listen_addr, "localhost") == 0 ||
            strcmp(listen_addr, "127.0.0.1") == 0 ||
            strcmp(listen_addr, "::1") == 0) {
            /* Accept localhost address when GatewayPorts=yes */
            addr = listen_addr;
        }

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list