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

Bug#548884: "apt-cache search" abort if locale is ja_JP.eucJP.



Package: apt
Version: 0.7.24
Severity: important
Tags: patch

"apt-cache search" abort if locale is ja_JP.eucJP.

$ locale
LANG=ja_JP.eucJP
LC_CTYPE="ja_JP.eucJP"
LC_NUMERIC="ja_JP.eucJP"
LC_TIME="ja_JP.eucJP"
LC_COLLATE="ja_JP.eucJP"
LC_MONETARY="ja_JP.eucJP"
LC_MESSAGES="ja_JP.eucJP"
LC_PAPER="ja_JP.eucJP"
LC_NAME="ja_JP.eucJP"
LC_ADDRESS="ja_JP.eucJP"
LC_TELEPHONE="ja_JP.eucJP"
LC_MEASUREMENT="ja_JP.eucJP"
LC_IDENTIFICATION="ja_JP.eucJP"
LC_ALL=
$ apt-cache search abcdefg
*** glibc detected *** apt-cache: free(): invalid next size (normal): 0x0000000001651ba0 ***
======= Backtrace: =========
/lib/libc.so.6[0x7ffad1ff76c8]
/lib/libc.so.6(cfree+0x76)[0x7ffad1ff91d6]
apt-cache[0x407266]
/usr/lib/libapt-pkg-libc6.9-6.so.4.8(_ZN11CommandLine11DispatchArgEPNS_8DispatchEb+0x55)[0x7ffad2ab84d5]
apt-cache[0x40969f]
/lib/libc.so.6(__libc_start_main+0xe6)[0x7ffad1fa45c6]
apt-cache[0x403679]
======= Memory map: ========
00400000-0040f000 r-xp 00000000 fe:02 11645                              /usr/bin/apt-cache
0060f000-00610000 rw-p 0000f000 fe:02 11645                              /usr/bin/apt-cache
01600000-01667000 rw-p 00000000 00:00 0                                  [heap]
7ffac8000000-7ffac8021000 rw-p 00000000 00:00 0 
7ffac8021000-7ffacc000000 ---p 00000000 00:00 0 
7ffacff62000-7ffad1762000 rw-p 00000000 00:00 0 
7ffad1762000-7ffad177a000 r-xp 00000000 fe:02 16931                      /usr/lib/gconv/libJIS.so
7ffad177a000-7ffad1979000 ---p 00018000 fe:02 16931                      /usr/lib/gconv/libJIS.so
7ffad1979000-7ffad197a000 r--p 00017000 fe:02 16931                      /usr/lib/gconv/libJIS.so
7ffad197a000-7ffad197b000 rw-p 00018000 fe:02 16931                      /usr/lib/gconv/libJIS.so
7ffad197b000-7ffad197e000 r-xp 00000000 fe:02 15895                      /usr/lib/gconv/EUC-JP.so
7ffad197e000-7ffad1b7d000 ---p 00003000 fe:02 15895                      /usr/lib/gconv/EUC-JP.so
7ffad1b7d000-7ffad1b7e000 r--p 00002000 fe:02 15895                      /usr/lib/gconv/EUC-JP.so
7ffad1b7e000-7ffad1b7f000 rw-p 00003000 fe:02 15895                      /usr/lib/gconv/EUC-JP.so
7ffad1b7f000-7ffad1b81000 r-xp 00000000 fe:01 1066                       /lib/libdl-2.9.so
7ffad1b81000-7ffad1d81000 ---p 00002000 fe:01 1066                       /lib/libdl-2.9.so
7ffad1d81000-7ffad1d82000 r--p 00002000 fe:01 1066                       /lib/libdl-2.9.so
7ffad1d82000-7ffad1d83000 rw-p 00003000 fe:01 1066                       /lib/libdl-2.9.so
7ffad1d83000-7ffad1d85000 r-xp 00000000 fe:01 1060                       /lib/libutil-2.9.so
7ffad1d85000-7ffad1f84000 ---p 00002000 fe:01 1060                       /lib/libutil-2.9.so
7ffad1f84000-7ffad1f85000 r--p 00001000 fe:01 1060                       /lib/libutil-2.9.so
7ffad1f85000-7ffad1f86000 rw-p 00002000 fe:01 1060                       /lib/libutil-2.9.so
7ffad1f86000-7ffad20cd000 r-xp 00000000 fe:01 922                        /lib/libc-2.9.so
7ffad20cd000-7ffad22cd000 ---p 00147000 fe:01 922                        /lib/libc-2.9.so
7ffad22cd000-7ffad22d1000 r--p 00147000 fe:01 922                        /lib/libc-2.9.so
7ffad22d1000-7ffad22d2000 rw-p 0014b000 fe:01 922                        /lib/libc-2.9.so
7ffad22d2000-7ffad22d7000 rw-p 00000000 00:00 0 
7ffad22d7000-7ffad22f1000 r-xp 00000000 fe:01 216                        /lib/libgcc_s.so.1
7ffad22f1000-7ffad24f0000 ---p 0001a000 fe:01 216                        /lib/libgcc_s.so.1
7ffad24f0000-7ffad24f1000 rw-p 00019000 fe:01 216                        /lib/libgcc_s.so.1
7ffad24f1000-7ffad2573000 r-xp 00000000 fe:01 913                        /lib/libm-2.9.so
7ffad2573000-7ffad2772000 ---p 00082000 fe:01 913                        /lib/libm-2.9.so
7ffad2772000-7ffad2773000 r--p 00081000 fe:01 913                        /lib/libm-2.9.so
7ffad2773000-7ffad2774000 rw-p 00082000 fe:01 913                        /lib/libm-2.9.so
7ffad2774000-7ffad2866000 r-xp 00000000 fe:02 69                         /usr/lib/libstdc++.so.6.0.13
7ffad2866000-7ffad2a66000 ---p 000f2000 fe:02 69                         /usr/lib/libstdc++.so.6.0.13
7ffad2a66000-7ffad2a6d000 r--p 000f2000 fe:02 69                         /usr/lib/libstdc++.so.6.0.13
7ffad2a6d000-7ffad2a6f000 rw-p 000f9000 fe:02 69                         /usr/lib/libstdc++.so.6.0.13
7ffad2a6f000-7ffad2a84000 rw-p 00000000 00:00 0 
7ffad2a84000-7ffad2b48000 r-xp 00000000 fe:02 5146                       /usr/lib/libapt-pkg-libc6.9-6.so.4.8.1
7ffad2b48000-7ffad2d47000 ---p 000c4000 fe:02 5146                       /usr/lib/libapt-pkg-libc6.9-6.so.4.8.1
7ffad2d47000-7ffad2d4c000 rw-p 000c3000 fe:02 5146                       /usr/lib/libapt-pkg-libc6.9-6.so.4.8.1
7ffad2d4c000-7ffad2d69000 r-xp 00000000 fe:01 918                        /lib/ld-2.9.so
7ffad2dc6000-7ffad2e50000 rw-p 00000000 00:00 0 
7ffad2e50000-7ffad2e57000 r--s 00000000 fe:02 814                        /usr/lib/gconv/gconv-modules.cache
7ffad2e57000-7ffad2e5f000 r--p 00000000 fe:02 15839                      /usr/share/locale/ja/LC_MESSAGES/libapt-pkg4.8.mo
7ffad2e5f000-7ffad2f5c000 r--p 00000000 fe:02 21                         /usr/lib/locale/locale-archive
7ffad2f5c000-7ffad2f60000 rw-p 00000000 00:00 0 
7ffad2f65000-7ffad2f68000 rw-p 00000000 00:00 0 
7ffad2f68000-7ffad2f69000 r--p 0001c000 fe:01 918                        /lib/ld-2.9.so
7ffad2f69000-7ffad2f6a000 rw-p 0001d000 fe:01 918                        /lib/ld-2.9.so
7fffac8c3000-7fffac8d8000 rw-p 00000000 00:00 0                          [stack]
7fffac9e0000-7fffac9e1000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
zsh: abort (core dumped)  apt-cache search abcdefg


-- Package-specific info:

-- apt-config dump --

APT "";
APT::Architecture "amd64";
APT::Build-Essential "";
APT::Build-Essential:: "build-essential";
APT::Install-Recommends "false";
APT::Install-Suggests "0";
APT::Acquire "";
APT::Acquire::Translation "environment";
APT::NeverAutoRemove "";
APT::NeverAutoRemove:: "^linux-image.*";
APT::NeverAutoRemove:: "^linux-restricted-modules.*";
Dir "/";
Dir::State "var/lib/apt/";
Dir::State::lists "lists/";
Dir::State::cdroms "cdroms.list";
Dir::State::userstatus "status.user";
Dir::State::status "/var/lib/dpkg/status";
Dir::Cache "var/cache/apt/";
Dir::Cache::archives "archives/";
Dir::Cache::srcpkgcache "srcpkgcache.bin";
Dir::Cache::pkgcache "pkgcache.bin";
Dir::Etc "etc/apt/";
Dir::Etc::sourcelist "sources.list";
Dir::Etc::sourceparts "sources.list.d";
Dir::Etc::vendorlist "vendors.list";
Dir::Etc::vendorparts "vendors.list.d";
Dir::Etc::main "apt.conf";
Dir::Etc::parts "apt.conf.d";
Dir::Etc::preferences "preferences";
Dir::Etc::preferencesparts "preferences.d";
Dir::Bin "";
Dir::Bin::methods "/usr/lib/apt/methods";
Dir::Bin::dpkg "/usr/bin/dpkg";
Dir::Log "var/log/apt";
Dir::Log::Terminal "term.log";
DPkg "";
DPkg::Pre-Install-Pkgs "";
DPkg::Pre-Install-Pkgs:: "/usr/sbin/dpkg-preconfigure --apt || true";

-- (no /etc/apt/preferences present) --


-- (no /etc/apt/sources.list present) --


-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.31
Locale: LANG=ja_JP.eucJP, LC_CTYPE=ja_JP.eucJP (charmap=EUC-JP)
Shell: /bin/sh linked to /bin/bash

Versions of packages apt depends on:
ii  debian-archive-keyring        2009.01.31 GnuPG archive keys of the Debian a
ii  libc6                         2.9-26     GNU C Library: Shared libraries
ii  libgcc1                       1:4.4.1-4  GCC support library
ii  libstdc++6                    4.4.1-4    The GNU Standard C++ Library v3

apt recommends no packages.

Versions of packages apt suggests:
pn  apt-doc                       <none>     (no description available)
pn  aptitude | synaptic | wajig   <none>     (no description available)
ii  bzip2                         1.0.5-3    high-quality block-sorting file co
ii  dpkg-dev                      1.15.4     Debian package development tools
ii  lzma                          4.43-14    Compression method of 7z format in
pn  python-apt                    <none>     (no description available)

-- no debconf information
--- apt-0.7.24.orig/apt-pkg/contrib/strutl.cc	2009-09-26 02:58:21.000000000 +0900
+++ apt-0.7.24/apt-pkg/contrib/strutl.cc	2009-09-29 12:20:44.896960589 +0900
@@ -43,8 +43,8 @@ bool UTF8ToCodeset(const char *codeset, 
 {
   iconv_t cd;
   const char *inbuf;
-  char *inptr, *outbuf, *outptr;
-  size_t insize, outsize;
+  char *inptr, *outbuf;
+  size_t insize, bufsize;
   
   cd = iconv_open(codeset, "UTF-8");
   if (cd == (iconv_t)(-1)) {
@@ -61,27 +61,41 @@ bool UTF8ToCodeset(const char *codeset, 
      return false;
   }
 
-  insize = outsize = orig.size();
+  insize = bufsize = orig.size();
   inbuf = orig.data();
   inptr = (char *)inbuf;
-  outbuf = new char[insize+1];
-  outptr = outbuf;
+  outbuf = new char[bufsize];
+  dest->clear();
 
   while (insize != 0)
   {
+     char *outptr = outbuf;
+     size_t outsize = bufsize;
      size_t const err = iconv(cd, &inptr, &insize, &outptr, &outsize);
+     dest->append(outbuf, outptr - outbuf);
      if (err == (size_t)(-1))
      {
-	insize--;
-	outsize++;
-	inptr++;
-	*outptr = '?';
-	outptr++;
+	switch (errno)
+	{
+	case EILSEQ:
+	   insize--;
+	   inptr++;
+	   break;
+	case EINVAL:
+	   insize = 0;
+	   break;
+	case E2BIG:
+	   if (outptr == outbuf)
+	   {
+	      bufsize *= 2;
+	      delete[] outbuf;
+	      outbuf = new char[bufsize];
+	   }
+	   break;
+	}
      }
   }
 
-  *outptr = '\0';
-  *dest = outbuf;
   delete[] outbuf;
   
   iconv_close(cd);

Reply to: