NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/38017: Coverity inspired changes to rpcinfo are incomplete and apparently were never actually tested



>Number:         38017
>Category:       bin
>Synopsis:       Coverity inspired changes to rpcinfo are incomplete and 
>apparently were never actually tested
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 13 15:25:00 +0000 2008
>Originator:     Greg A. Woods
>Release:        NetBSD 4.0_STABLE 2008/02/12
>Organization:
Planix, Inc.; Toronto, Ontario; Canada
>Environment:
System: NetBSD 4.0_STABLE GENERIC.MP
Architecture: i386
Machine: i386
>Description:

        "rpcinfo -s" output is incorrect after rev. 1.26 of 
src/usr.bin/rpcinfo.c

        When changes are inspired by some arbitrary code audit of any
        kind then extensive testing of those changes is mandatory!  In
        most cases the code probably worked even if it wasn't as clean
        or safe or ideal as it might be possible to make it.

        Breaking working code just because some audit (especially one by
        an automated tool) said it was questionable is simply not
        acceptable.

>How-To-Repeat:

        issue an "rpcinfo -s" request on (or to) a host running rpcbind
        and observe that the same program number and service name is now
        reported for many services:

        NetBSD-4.0 $ rpcinfo -s
           program version(s) netid(s)                         service     owner
            100000  2,3,4     local                            portmapper  
superuser
            100000  2         udp                              portmapper  
superuser
            100000  3         udp                              portmapper  
superuser
            100000  2         tcp                              portmapper  
superuser
            100000  3         tcp                              portmapper  
superuser
            100000  1         udp                              portmapper  
superuser
            100000  3         udp                              portmapper  
superuser
            100000  1         tcp                              portmapper  
superuser
            100000  3         tcp                              portmapper  
superuser
            100000  1         udp                              portmapper  
superuser
            100000  2         udp                              portmapper  
superuser
            100000  3         udp                              portmapper  
superuser
            100000  2         udp                              portmapper  
superuser
            100000  3         udp                              portmapper  
superuser
            100000  1         udp                              portmapper  
superuser
            100000  1         udp                              portmapper  
superuser
            100000  2         udp                              portmapper  
superuser
        
        it should look like this:

        NetBSD-1.6.2 $ rpcinfo -s
           program version(s) netid(s)                         service     owner
            100000  2,3,4     local                            portmapper  
superuser
            100003  3,2       tcp,udp                          nfs         
superuser
            100005  3,1       tcp,udp                          mountd      
superuser
            100001  3,2,1     udp                              rstatd      
superuser
            100002  3,2       udp                              rusersd     
superuser
            100008  1         udp                              walld       
superuser
            100011  2,1       udp                              rquotad     
superuser


>Fix:

        I'm not sure if this is the complete fix, but it does seem to
        cause the correct output to appear once again for at least the
        simplest usage case:

Index: usr.bin/rpcinfo/rpcinfo.c
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/usr.bin/rpcinfo/rpcinfo.c,v
retrieving revision 1.26
diff -u -r1.26 rpcinfo.c
--- usr.bin/rpcinfo/rpcinfo.c   24 May 2006 16:04:03 -0000      1.26
+++ usr.bin/rpcinfo/rpcinfo.c   13 Feb 2008 14:44:17 -0000
@@ -853,8 +853,8 @@
                                        rs_tail->next = rs;
                                        rs_tail = rs;
                                }
-                               rs->prog = head->rpcb_map.r_prog;
-                               rs->owner = head->rpcb_map.r_owner;
+                               rs->prog = p->rpcb_map.r_prog;
+                               rs->owner = p->rpcb_map.r_owner;
                                rs->nlist = NULL;
                                rs->vlist = NULL;
                        }



Home | Main Index | Thread Index | Old Index