<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>23813</bug_id>
          
          <creation_ts>2010-07-26 18:14:14 +0400</creation_ts>
          <short_desc>Падает с Segmentation fault</short_desc>
          <delta_ts>2010-08-06 04:58:29 +0400</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>rpm-build</component>
          <version>unstable</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ivan Fedorov">ns</reporter>
          <assigned_to name="placeholder@altlinux.org">placeholder</assigned_to>
          <cc>aen</cc>
    
    <cc>arseny</cc>
    
    <cc>glebfm</cc>
    
    <cc>imz</cc>
    
    <cc>ldv</cc>
    
    <cc>placeholder</cc>
    
    <cc>vt</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>110805</commentid>
    <comment_count>0</comment_count>
      <attachid>4466</attachid>
    <who name="Ivan Fedorov">ns</who>
    <bug_when>2010-07-26 18:14:14 +0400</bug_when>
    <thetext>Created attachment 4466
минимальный спек на котором падает

$ rpm -bb segfault.spec 
Processing files: segfault-1.0-alt1
Segmentation fault</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110806</commentid>
    <comment_count>1</comment_count>
    <who name="Andrey Rahmatullin">wrar</who>
    <bug_when>2010-07-26 18:43:35 +0400</bug_when>
    <thetext>Раз уж у меня в системе rpm с дебагом...


(gdb) bt
#0  0x4efa1f91 in strlen () from /lib/libc.so.6
#1  0xb7f703e3 in parseForSimple (spec=0x80763d0, pkg=0x8075108, buf=0xbfff8bec &quot;%dir&quot;, fl=0xbfff7b0c, fileName=0xbfff8bd8) at files.c:893
#2  0xb7f737b7 in processPackageFiles (spec=0x80763d0, pkg=0x8075108, installSpecialDoc=4, test=0) at files.c:2013
#3  0xb7f76c26 in processBinaryFiles (spec=0x80763d0, installSpecialDoc=4, test=0) at files.c:3228
#4  0xb7f6cb0d in buildSpec (spec=0x80763d0, what=159, test=0) at build.c:340
#5  0x0804abcf in buildForTarget (arg=0xbffff213 &quot;tmp/segfault.spec&quot;, ba=0x804e500, passPhrase=0x804c964 &quot;&quot;, cookie=0x0) at build.c:311
#6  0x0804acbe in build (arg=0xbffff213 &quot;tmp/segfault.spec&quot;, ba=0x804e500, passPhrase=0x804c964 &quot;&quot;, cookie=0x0, rcfile=0x0) at build.c:336
#7  0x0804c112 in main (argc=3, argv=0xbffff004) at rpmqv.c:1038

(gdb) fr 1
#1  0xb7f703e3 in parseForSimple (spec=0x80763d0, pkg=0x8075108, buf=0xbfff8bec &quot;%dir&quot;, fl=0xbfff7b0c, fileName=0xbfff8bd8) at files.c:893
893                 fl-&gt;docDirs[fl-&gt;docDirCount++] = xstrdup(s);
(gdb) p s
$1 = 0x0
(gdb) list
888                 if (fl-&gt;docDirCount == MAXDOCDIR) {
889                     rpmError(RPMERR_INTERNAL, _(&quot;Hit limit for %%docdir\n&quot;));
890                     fl-&gt;processingFailed = 1;
891                     res = 1;
892                 }
893                 fl-&gt;docDirs[fl-&gt;docDirCount++] = xstrdup(s);
894                 if (strtokWithQuotes(NULL, &quot; \t\n&quot;)) {
895                     rpmError(RPMERR_INTERNAL, _(&quot;Only one arg for %%docdir\n&quot;));
896                     fl-&gt;processingFailed = 1;
897                     res = 1;

Мало того, что xstrdup не проверяет параметр на NULL, сразу суя его в strlen(3), так код, проверяющий результат strtokWithQuotes, соседствует с кодом, его не проверяющим.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110807</commentid>
    <comment_count>2</comment_count>
    <who name="Ivan Fedorov">ns</who>
    <bug_when>2010-07-26 19:17:34 +0400</bug_when>
    <thetext>(В ответ на комментарий №1)
&gt; Раз уж у меня в системе rpm с дебагом...

Как??? Я за 15-ть минут не нашел, хотя ldv@ сказал что там &quot;всё просто&quot; включается... :(</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110808</commentid>
    <comment_count>3</comment_count>
    <who name="Andrey Rahmatullin">wrar</who>
    <bug_when>2010-07-26 19:21:29 +0400</bug_when>
    <thetext>gear-hsh --build-args=&quot;--enable debug&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111037</commentid>
    <comment_count>4</comment_count>
    <who name="Repository Robot">repository-robot</who>
    <bug_when>2010-08-06 04:58:29 +0400</bug_when>
    <thetext>rpm-4.0.4-alt98.40 -&gt; sisyphus:

* Thu Aug 05 2010 Alexey Tourbin &lt;at@altlinux&gt; 4.0.4-alt98.40
- build/files.c (parseForSimple): Fix potential NULL pointer dereference
  (Dmitry V. Levin, ALT#23813).
- depends.c (dbSatisfiesDepend): Use strdup for dbProvCache keys
  to avoid dangling pointers (ALT#23813).</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>4466</attachid>
            <date>2010-07-26 18:14:14 +0400</date>
            <delta_ts>2010-07-26 18:14:14 +0400</delta_ts>
            <desc>минимальный спек на котором падает</desc>
            <filename>segfault.spec</filename>
            <type>application/octet-stream</type>
            <size>163</size>
            <attacher name="Ivan Fedorov">ns</attacher>
            
              <data encoding="base64">Ck5hbWU6IHNlZ2ZhdWx0ClZlcnNpb246IDEuMApSZWxlYXNlOiBhbHQxCgpTdW1tYXJ5OiBTZWdt
ZW50YXRpb24gRmF1bHQKTGljZW5zZTogUHVibGljIGRvbWFpbgpHcm91cDogU3lzdGVtL0xpYnJh
cmllcwoKJWRlc2NyaXB0aW9uCiVzdW1tYXJ5CgolZmlsZXMKJWRpciAlZG9jZGlyCg==
</data>

          </attachment>
      

    </bug>

</bugzilla>