<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>110663</bug_id>
          
          <creation_ts>2005-10-27 19:07 0000</creation_ts>
          <short_desc>bus error on mt-daapd ~sparc (and suggested fix)</short_desc>
          <delta_ts>2006-01-04 07:12:11 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Server</component>
          <version>unspecified</version>
          <rep_platform>Sparc</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>paulf@aphrodite.com</reporter>
          <assigned_to>sparc@gentoo.org</assigned_to>
          <cc>sound@gentoo.org</cc>

      

      
          <long_desc isprivate="0">
            <who>paulf@aphrodite.com</who>
            <bug_when>2005-10-27 19:07:25 0000</bug_when>
            <thetext>I know ~sparc isn&apos;t in the keywords probably for a reason, but I actually got it up and going with a 
patch in &quot;additional information&quot;.

I&apos;ve posted this on mt-daapd&apos;s forums so the maintainer is aware.  In the meantime, you may patch mt-
daapd-0.2.3-r1 to fix two alignment errors.  So far this change allows it to run on my machine with my 
music files.  Of course there may be other alignment errors lurking in the code that I am unaware of 
since I don&apos;t maintain this software.


Reproducible: Always
Steps to Reproduce:
ebuild mt-daapd-0.2.3-r1.ebuild (since keywords are missing ~sparc I can&apos;t emerge it)
configure it against mp3 files containing xing headers (or at least ones whose 32-bit header data isn&apos;t on 
a 4 byte alignment boundary within the file)
run it

Actual Results:  
files containing xing headers cause mt-daapd to crash with a bus error (alignment exception) due to 
deference of unaligned pointer.


emege info follows patch:

*** mp3-scanner.c.orig  Thu Oct 27 18:34:01 2005
--- mp3-scanner.c   Thu Oct 27 18:32:58 2005
***************
*** 1663,1676 ****
      /* now check for an XING header */
      if(strncasecmp((char*)&amp;buffer[index+fi.xing_offset+4],&quot;XING&quot;,4) == 0) {
        DPRINTF(E_DBG,L_SCAN,&quot;Found Xing header\n&quot;);
!       xing_flags=*((int*)&amp;buffer[index+fi.xing_offset+4+4]);
        xing_flags=ntohs(xing_flags);
  
        DPRINTF(E_DBG,L_SCAN,&quot;Xing Flags: %02X\n&quot;,xing_flags);
  
        if(xing_flags &amp; 0x1) {
            /* Frames field is valid... */
!           fi.number_of_frames=*((int*)&amp;buffer[index+fi.xing_offset+4+8]);
  
            fi.number_of_frames=ntohs(fi.number_of_frames);
        }
--- 1663,1676 ----
      /* now check for an XING header */
      if(strncasecmp((char*)&amp;buffer[index+fi.xing_offset+4],&quot;XING&quot;,4) == 0) {
        DPRINTF(E_DBG,L_SCAN,&quot;Found Xing header\n&quot;);
!       memcpy (&amp;xing_flags, &amp;buffer[index+fi.xing_offset+4+4], 4);
        xing_flags=ntohs(xing_flags);
  
        DPRINTF(E_DBG,L_SCAN,&quot;Xing Flags: %02X\n&quot;,xing_flags);
  
        if(xing_flags &amp; 0x1) {
            /* Frames field is valid... */
!             memcpy (&amp;fi.number_of_frames, &amp;buffer[index+fi.xing_offset+4+8], 
);
  
            fi.number_of_frames=ntohs(fi.number_of_frames);
        }


emerge info:
Portage 2.0.51.22-r3 (default-linux/sparc/sparc64/2005.0, gcc-3.3.5-20050130, 
glibc-2.3.3.20040420-r2, 2.4.31-sparc-r2 sparc64)
===============================================================
==
System uname: 2.4.31-sparc-r2 sparc64 sun4u
Gentoo Base System version 1.6.13
dev-lang/python:     2.3.5, 2.4.2
sys-apps/sandbox:    1.2.12
sys-devel/autoconf:  2.13, 2.59-r6
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1
sys-devel/binutils:  2.15.92.0.2-r10
sys-devel/libtool:   1.5.20
virtual/os-headers:  2.4.23
ACCEPT_KEYWORDS=&quot;sparc&quot;
AUTOCLEAN=&quot;yes&quot;
CBUILD=&quot;sparc-unknown-linux-gnu&quot;
CFLAGS=&quot;-O2 -pipe&quot;
CHOST=&quot;sparc-unknown-linux-gnu&quot;
CONFIG_PROTECT=&quot;/etc /usr/kde/2/share/config /usr/kde/3/share/config /usr/share/config /var/
qmail/control&quot;
CONFIG_PROTECT_MASK=&quot;/etc/gconf /etc/env.d&quot;
CXXFLAGS=&quot;-O2 -pipe&quot;
DISTDIR=&quot;/usr/portage/distfiles&quot;
FEATURES=&quot;autoconfig ccache distlocks sandbox sfperms strict&quot;
GENTOO_MIRRORS=&quot;http://distfiles.gentoo.org http://distro.ibiblio.org/pub/Linux/distributions/
gentoo&quot;
PKGDIR=&quot;/usr/portage/packages&quot;
PORTAGE_TMPDIR=&quot;/var/tmp&quot;
PORTDIR=&quot;/usr/portage&quot;
SYNC=&quot;rsync://rsync.gentoo.org/gentoo-portage&quot;
USE=&quot;sparc arts avi berkdb bitmap-fonts crypt cups curl dlloader encode esd fbcon foomaticdb fortran 
gcc64 gdbm gif gnome gtk gtk2 howl imlib jpeg kde libwww mad mikmod motif mpeg ncurses nls 
oggvorbis opengl oss pam pdflib perl plotutils png python qt readline samba sdl spell ssl tcpd tiff 
truetype truetype-fonts type1-fonts xml2 xmms xv zlib userland_GNU kernel_linux elibc_glibc&quot;
Unset:  ASFLAGS, CTARGET, LANG, LC_ALL, LDFLAGS, LINGUAS, MAKEOPTS, PORTDIR_OVERLAY</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>gustavoz@gentoo.org</who>
            <bug_when>2005-11-04 11:42:38 0000</bug_when>
            <thetext>Please attach patches instead of inlining them...
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>flameeyes@gentoo.org</who>
            <bug_when>2005-12-01 10:56:20 0000</bug_when>
            <thetext>Can you please attach an unified patch? 
 </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>paulf@aphrodite.com</who>
            <bug_when>2005-12-01 14:02:36 0000</bug_when>
            <thetext>Created an attachment (id=73909)
unaligned pointer access reading xing headers
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>flameeyes@gentoo.org</who>
            <bug_when>2005-12-01 14:07:54 0000</bug_when>
            <thetext>Please use diff -ur that&apos;s unified diff, simpler to read :) </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>paulf@aphrodite.com</who>
            <bug_when>2005-12-01 14:12:01 0000</bug_when>
            <thetext>I&apos;ll do that next time.  In the meantime the only easily accessible record I have of that diff is what I left in 
this bug report.  Take it or leave it.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>gustavoz@gentoo.org</who>
            <bug_when>2006-01-03 12:01:58 0000</bug_when>
            <thetext>Created an attachment (id=76102)
Unified and cleaned-up patch

Made a clean and unified patch.
Diego: tested here against rhythmbox, if you&apos;re ok commit and ~sparc mt-daapd-0.9.2-r2.
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>gustavoz@gentoo.org</who>
            <bug_when>2006-01-03 12:03:13 0000</bug_when>
            <thetext>Oops, i mean 0.2.3-r2 :)
Got that nagging rhythmbox version on my brain.
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>flameeyes@gentoo.org</who>
            <bug_when>2006-01-04 07:12:11 0000</bug_when>
            <thetext>Committed and ~sparc-ed.
</thetext>
          </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>73909</attachid>
            <date>2005-12-01 14:02 0000</date>
            <desc>unaligned pointer access reading xing headers</desc>
            <filename>patch</filename>
            <type>text/plain</type>
            <data encoding="base64">KioqIG1wMy1zY2FubmVyLmMub3JpZyAgVGh1IE9jdCAyNyAxODozNDowMSAyMDA1Ci0tLSBtcDMt
c2Nhbm5lci5jICAgVGh1IE9jdCAyNyAxODozMjo1OCAyMDA1CioqKioqK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2luZGV4K2ZpLnhpbmdfb2Zmc2V0KzQrNF0sIDQpOwogICAgICAgIHhpbmdfZmxh
Z3M9bnRvaHMoeGluZ19mbGFncyk7CiAgCiAgICAgICAgRFBSSU5URihFX0RCRyxMX1NDQU4sIlhp
bmcgRmxhZ3M6ICUwMlhcbiIseGluZ19mbGFncyk7CiAgCiAgICAgICAgaWYoeGluZ19mbGFncyAm
IDB4MSkgewogICAgICAgICAgICAvKiBGcmFtZXMgZmllbGQgaXMgdmFsaWQuLi4gKi8KISAgICAg
ICAgICAgICBtZW1jcHkgKCZmaS5udW1iZXJfb2ZfZnJhbWVzLCAmYnVmZmVyW2luZGV4K2ZpLnhp
bmdfb2Zmc2V0KzQrOF0sIAopOwogIAogICAgICAgICAgICBmaS5udW1iZXJfb2ZfZnJhbWVzPW50
b2hzKGZpLm51bWJlcl9vZl9mcmFtZXMpOwogICAgICAgIH0KCg==
</data>        

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>76102</attachid>
            <date>2006-01-03 12:01 0000</date>
            <desc>Unified and cleaned-up patch</desc>
            <filename>mt-daapd-0.2.3-memcpy.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">ZGlmZiAtTnVyYSBtdC1kYWFwZC0wLjIuMy9zcmMvbXAzLXNjYW5uZXIuYyBtdC1kYWFwZC0wLjIu
My5zcGFyYy9zcmMvbXAzLXNjYW5uZXIuYwotLS0gbXQtZGFhcGQtMC4yLjMvc3JjL21wMy1zY2Fu
bmVyLmMJMjAwNS0wMi0wNSAxODoyMjo0Ny4wMDAwMDAwMDAgLTAzMDAKKysrIG10LWRhYXBkLTAu
Mi4zLnNwYXJjL3NyYy9tcDMtc2Nhbm5lci5jCTIwMDYtMDEtMDMgMTY6Mzk6NTAuMDAwMDAwMDAw
IC0wMzAwCkBAIC0xNjYzLDE0ICsxNjYzLDE0IEBACiAgICAgLyogbm93IGNoZWNrIGZvciBhbiBY
SU5HIGhlYWRlciAqLwogICAg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