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

Bug#120311: apt-cache segfaults on malformed status-file



Culus said "MMap *Map = 0;" was the right fix.

It isn't.

zuul:/# LD_LIBRARY_PATH=/tmp/branden/apt-0.5.4/build/bin gdb /tmp/branden/apt-0.5.4/build/bin/apt-cache
GNU gdb 2002-08-18-cvs
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-linux"...
(gdb) set args show autoconf
(gdb) break apt-cache.cc:1359
Breakpoint 1 at 0x8052a41: file apt-cache.cc, line 1359.
(gdb) run
Starting program: /tmp/branden/apt-0.5.4/build/bin/apt-cache show autoconf

Breakpoint 1, main (argc=3, argv=0xbffffd24) at apt-cache.cc:1359
1359       if (ttyname(STDOUT_FILENO) == 0 && _config->FindI("quiet",0) < 1)
(gdb) next
1362       if (CmdL.DispatchArg(CmdsA,false) == false && _error->PendingError() == false)
(gdb) 
1364          MMap *Map = 0;
(gdb) 
1365          if (_config->FindB("APT::Cache::Generate",true) == false)
(gdb) 
1373             SrcList = new pkgSourceList;
(gdb) 
1374             SrcList->ReadMainList();
(gdb) 
1377             OpProgress Prog;
(gdb) 
1378             pkgMakeStatusCache(*SrcList,Prog,&Map,true);
(gdb) 
68         virtual ~OpProgress() {};
(gdb) 
147       Rep *rep () const { return reinterpret_cast<Rep *>(dat) - 1; }
(gdb) 
109         void release () { if (--ref == 0) delete this; }
(gdb) 
190         { rep ()->release (); }
(gdb) 
109         void release () { if (--ref == 0) delete this; }
(gdb) 
428       {
(gdb) 
432         if (__n > (size_t) _MAX_BYTES) {
(gdb) 
347             return (((__bytes) + _ALIGN-1)/_ALIGN - 1);
(gdb) 
436         __my_free_list = _S_free_list + _S_freelist_index(__n);
(gdb) 
393                 _Lock() { __NODE_ALLOCATOR_LOCK; }
(gdb) 
442         __q -> _M_free_list_link = *__my_free_list;
(gdb) 
443         *__my_free_list = __q;
(gdb) 
394                 ~_Lock() { __NODE_ALLOCATOR_UNLOCK; }
(gdb) 
190         { rep ()->release (); }
(gdb) 
109         void release () { if (--ref == 0) delete this; }
(gdb) 
190         { rep ()->release (); }
(gdb) 
109         void release () { if (--ref == 0) delete this; }
(gdb) 
1381          if (_error->PendingError() == false)
(gdb) 
1388          if (Map)
(gdb) 
1391            return _error->Error(_("I AM IN A WORLD OF SHIT"));
0x08053505      1404    }
(gdb) 
0x401850bf in __libc_start_main () from /lib/libc.so.6
(gdb) 
Single stepping until exit from function __libc_start_main, 
which has no line number information.

Program exited normally.

I.e., it still doesn't work.

Interestingly, if apt-cache show is run as a normal user instead of root, it
works.  At least in the case I'm seeing.

diff -u cmdline/apt-cache.cc.culus cmdline/apt-cache.cc
--- cmdline/apt-cache.cc.culus  2002-09-12 15:27:20.000000000 -0500
+++ cmdline/apt-cache.cc        2002-09-12 15:39:22.000000000 -0500
@@ -1361,7 +1361,7 @@
 
    if (CmdL.DispatchArg(CmdsA,false) == false && _error->PendingError() == false)
    { 
-      MMap *Map;
+      MMap *Map = 0;
       if (_config->FindB("APT::Cache::Generate",true) == false)
       {
         Map = new MMap(*new FileFd(_config->FindFile("Dir::Cache::pkgcache"),
@@ -1385,7 +1385,11 @@
         if (_error->PendingError() == false)
            CmdL.DispatchArg(CmdsB);
       }
-      delete Map;
+      if (Map)
+         delete Map;
+      else
+       return _error->Error(_("I AM IN A WORLD OF SHIT"));
+
    }
    
    // Print any errors or warnings found during parsing

-- 
G. Branden Robinson                |    A celibate clergy is an especially
Debian GNU/Linux                   |    good idea, because it tends to
branden@debian.org                 |    suppress any hereditary propensity
http://people.debian.org/~branden/ |    toward fanaticism.    -- Carl Sagan

Attachment: pgpo7qYRLOmPJ.pgp
Description: PGP signature


Reply to: