Hi hajma,

In stack frame 6, the third parameter is zero. It can be seen
in the source code to kpropertiesdialog.cpp that it passes
a zero groups parameter, so the caller seems to think that
getgroupslist will just return the necessary buffer count for
the groups in this case.  However in the source code:

http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/ssh/libopenbsd-compat/common/getgrouplist.c

it just sigsegvs if the groups is zero.

So one idea is to try to avoid the sigsegv, and try to come
up with a count that is big enough for the buffer, which may
be bigger than the actual number of groups, when the groups is zero.
That seems like it should be OK, as the second time getgroupslist
is called with a non-zero groups, it then returns the correct
number of groups.

This is untested.

Thanks, Mark

*** orig/getgrouplist.c 2009-03-19 22:06:02.000000000 +1100
--- getgrouplist.c      2009-08-22 11:00:00.947806967 +1000
***************
*** 69,75 ****
                *grpcnt = ngroups;
                return (-1);
        }
!       groups[ngroups++] = agroup;
  
        /*
         * Scan the group file to find additional groups.
--- 69,75 ----
                *grpcnt = ngroups;
                return (-1);
        }
!       groups ? groups[ngroups++] = agroup : ngroups++;
  
        /*
         * Scan the group file to find additional groups.
***************
*** 78,95 ****
        while ((grp = getgrent())) {
                if (grp->gr_gid == agroup)
                        continue;
                for (bail = 0, i = 0; bail == 0 && i < ngroups; i++)
                        if (groups[i] == grp->gr_gid)
                                bail = 1;
                if (bail)
                        continue;
                for (i = 0; grp->gr_mem[i]; i++) {
                        if (!strcmp(grp->gr_mem[i], uname)) {
                                if (ngroups >= maxgroups) {
                                        ret = -1;
                                        goto out;
                                }
!                               groups[ngroups++] = grp->gr_gid;
                                break;
                        }
                }
--- 78,97 ----
        while ((grp = getgrent())) {
                if (grp->gr_gid == agroup)
                        continue;
+     if (groups) {
        for (bail = 0, i = 0; bail == 0 && i < ngroups; i++)
          if (groups[i] == grp->gr_gid)
            bail = 1;
        if (bail)
          continue;
+     }
                for (i = 0; grp->gr_mem[i]; i++) {
                        if (!strcmp(grp->gr_mem[i], uname)) {
                                if (ngroups >= maxgroups) {
                                        ret = -1;
                                        goto out;
                                }
!                               groups ? groups[ngroups++] = grp->gr_gid : 
ngroups++;
                                break;
                        }
                }



On Tue, 18 Aug 2009 09:29:57 PDT
Pavel Heimlich <tropikhajma at gmail.com> wrote:

> Hi,
> according to the core generated* after the crash caused by right clicking an 
> icon on desktop and selecting 'Properties' it seems the crash is happening 
> due to the getgrouplist function that we've added in this patch 
> http://solaris.bionicmutton.org/hg/kde4-specs-42/file/754d581006d7/specs/patches/kdelibs-getgrouplist.diff
> Could some C++ positive soul please have a look at the patch and the 
> kpropertiesdialog.cpp file 
> http://websvn.kde.org/trunk/KDE/kdelibs/kio/kfile/kpropertiesdialog.cpp?revision=990257&view=markup
> and try to figure out what's wrong?
> 
> Also could we perhaps solve it by getting rid of the patch altogether and 
> just reverting this change for open/solaris?
> http://websvn.kde.org/trunk/KDE/kdelibs/kio/kfile/kpropertiesdialog.cpp?r1=933028&r2=935834
> 
> regards
> 
> hajma
> 
>                                                                               
>                            
> current thread: t at 1                                                        
>                                                   
> =>[1] libc.so.1:_lwp_kill(0x1, 0xb, 0xcdac2bb6, 0xcdafa9fa), at 0xcdb022a5    
>                                                
>   [2] libc.so.1:thr_kill(0x1, 0xb, 0x803ebc8, 0xcdaaab7e), at 0xcdafaa1c      
>                                                
>   [3] libc.so.1:raise(0xb, 0x0), at 0xcdaaab8a                                
>                                                
>   [4] libkdeui.so.5.3.0:KCrash::defaultCrashHandler(0xb, 0x0, 0x803eff4), at 
> 0xcc83cffb                                      
>   [5] libc.so.1:__sighndlr(0xb, 0x0, 0x803eff4, 0xcc83cd80), at 0xcdafd0cf    
>                                                
>   ---- called from signal handler with signal 11 (SIGSEGV) ------             
>                                                
>   [6] libkio.so.5.3.0:getgrouplist(0x81d7a40, 0xa, 0x0, 0x80401a4, 0x0, 0x0), 
> at 0xc9828e5e                                  
>   [7] 
> libkio.so.5.3.0:KDEPrivate::KFilePermissionsPropsPlugin::KFilePermissionsPropsPlugin(0x81520e8,
>  0x8ef05d0), at 0xc9845d05                                                    
>                                                                        
>   [8] 
> libkio.so.5.3.0:KPropertiesDialog::KPropertiesDialogPrivate::insertPages(0x8f0d798,
>  0x0), at 0xc982d7a3                
>   [9] 
> libkio.so.5.3.0:KPropertiesDialog::KPropertiesDialogPrivate::init(0x8f0d798, 
> 0x0), at 0xc982ba7c                       
>   [10] libkio.so.5.3.0:KPropertiesDialog::KPropertiesDialog(0x8ef05d0, 
> 0x8e2a9a8, 0x81b9180), at 0xc982967b                  
>   [11] libkio.so.5.3.0:KPropertiesDialog::showDialog(0x8e2a9a8, 0x81b9180, 
> 0x0), at 0xc982b44a                               
>   [12] libkio.so.5.3.0:KPropertiesDialog::showDialog(0x804092c, 0x81b9180, 
> 0x0, 0xb9becd49), at 0xc982b7c5                   
>   [13] libkonq.so.5.3.0:KonqPopupMenuPrivate::slotPopupProperties(0x8eef050, 
> 0x0, 0x6, 0x8040b20), at 0xb9becd80             
>   [14] libkonq.so.5.3.0:KonqPopupMenu::qt_metacall(0x81cc4b8, 0x0, 0x2c, 
> 0x8040b20, 0x0, 0x0), at 0xb9bed6cd                 
>   [15] libQtCore.so.4.5.2:QMetaObject::activate(0x89f9750, 0x5, 0x6, 
> 0x8040b20, 0x0, 0x0), at 0xc9f5e888                     
>   [16] libQtCore.so.4.5.2:QMetaObject::activate(0x89f9750, 0xcba5e454, 0x1, 
> 0x2, 0x8040b20, 0x0), at 0xc9f5edb5              
>   [17] libQtGui.so.4.5.2:QAction::triggered(0x89f9750, 0x0), at 0xca9ffb83    
>                                                
>   [18] libQtGui.so.4.5.2:QAction::activate(0x89f9750, 0x0), at 0xca9fedfa


-- 

Reply via email to