Ticket #1563 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

Crash in TRM lookup

Reported by: urs_fleisch@yahoo.de Assigned to: luks
Priority: important Milestone:
Component: libtunepimp Version:
Keywords: TRM lookup segmentation fault crash Cc:
Browser: Opera OS: Linux

Description (Last modified by luks)

libtunepimp, version 0.4.2

I reported this to Debian, it might be interesting for you too.

Bug reproduction: Start tp_tagger (from packet libtunepimp-bin), add some MP3 or Ogg files and notice that the lookup process is stuck at "TRM Lookup". If you start tp_tagger from gdb, the lookup thread is reported to crash with a segmentation fault in LookupTRM::lookup(), the location can be found out using a libtunepimp.so.3.0.0 with debugging information not stripped, it is line 170.

Analysis: lib/lookuptools.cpp: At line 163, buffer temp is used as a buffer with 256 bytes. However, there is no buffer temp with 256 bytes in the innermost scope. The buffer temp used is defined in line 56 and has only 100 bytes. Thus when more than 100 bytes result data are read, temp is overflown and the thread can crash (if it does may depend on compiler optimization, linkage, ..., in my system it does).

Patch: The following patch provides a sufficiently sized temp buffer. It also fixes some other buffer length violations (one byte more is used than available).

diff -ru libtunepimp-0.4.2.orig/lib/lookuptools.cpp libtunepimp-0.4.2/lib/lookuptools.cpp
--- libtunepimp-0.4.2.orig/lib/lookuptools.cpp	2006-01-28 21:35:42.000000000 +0100
+++ libtunepimp-0.4.2/lib/lookuptools.cpp	2006-06-04 20:09:51.000000000 +0200
@@ -51,7 +51,7 @@
     musicbrainz_t  o;
     char          *args[7];
     int            ret, trackNum;
-    char           error[255], data[255], trackURI[256],
+    char           error[256], data[256], trackURI[256],
                    artistURI[256], albumURI[256];
     char           temp[100], duration[100], status[100];
 
@@ -159,6 +159,7 @@
             // Select the first release date
             if (mb_Select1(o, MBS_SelectReleaseDate, j))
             {
+                char temp[256];
                 // Pull back the release date and release country
                 if (mb_GetResultData(o, MBE_ReleaseGetDate, temp, 256))
                 {
@@ -211,7 +212,7 @@
     musicbrainz_t  o;
     char          *args[3];
     int            ret;
-    char           error[255], data[255];
+    char           error[256], data[256];
 
     // -----------------------------------------------------------------------------------------
     // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
@@ -299,7 +300,7 @@
 {
     musicbrainz_t  o;
     int            ret;
-    char           error[255];
+    char           error[256];
 
     if (user.empty() || passwd.empty())
     {
** end of patch **


And now for something completely different:
It would be better to check for taglib 1.4 than 1.4.0 in configure, or taglib with version "1.4" will not be used. The following patch should solve this:

** begin of patch **
#!diff
diff -ru libtunepimp-0.4.2.orig/configure libtunepimp-0.4.2/configure
--- libtunepimp-0.4.2.orig/configure	2006-06-04 23:47:52.000000000 +0200
+++ libtunepimp-0.4.2/configure	2006-06-02 19:30:24.000000000 +0200
@@ -19556,9 +19556,9 @@
     echo "*** Or see http://developer.kde.org/~wheeler/taglib.html"
   else
     TAGLIB_VERSION=`$TAGLIB_CONFIG --version`
-    echo "$as_me:$LINENO: checking for taglib >= 1.4.0" >&5
-echo $ECHO_N "checking for taglib >= 1.4.0... $ECHO_C" >&6
-        VERSION_CHECK=`expr $TAGLIB_VERSION \>\= 1.4.0`
+    echo "$as_me:$LINENO: checking for taglib >= 1.4" >&5
+echo $ECHO_N "checking for taglib >= 1.4... $ECHO_C" >&6
+        VERSION_CHECK=`expr $TAGLIB_VERSION \>\= 1.4`
         if test "$VERSION_CHECK" = "1" ; then
             echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
diff -ru libtunepimp-0.4.2.orig/configure.in libtunepimp-0.4.2/configure.in
--- libtunepimp-0.4.2.orig/configure.in	2006-06-04 23:47:52.000000000 +0200
+++ libtunepimp-0.4.2/configure.in	2006-06-04 23:45:25.000000000 +0200
@@ -77,7 +77,7 @@
 AC_CHECK_HEADERS(iconv.h)
 
 dnl Check for TagLib 1.4
-AC_CHECK_TAGLIB(1.4.0, 
+AC_CHECK_TAGLIB(1.4, 
                 [TP_PLUGINS="$TP_PLUGINS mpc wma"
                 AC_DEFINE(HAVE_TAGLIB,1,[TagLib Support])],
 		[AC_MSG_RESULT([no])

Attachments

lookup_patch.diff (1.4 kB) - added by urs_fleisch@yahoo.de on 2006-06-04 23:02:51.
patch fixing TRM lookup crash
configure_patch.diff (1.3 kB) - added by urs_fleisch@yahoo.de on 2006-06-04 23:04:40.
Patch to accept taglib >= 1.4 (and not 1.4.0)

Change History

2006-06-04 23:02:51 changed by urs_fleisch@yahoo.de

  • attachment lookup_patch.diff added.

patch fixing TRM lookup crash

2006-06-04 23:04:40 changed by urs_fleisch@yahoo.de

  • attachment configure_patch.diff added.

Patch to accept taglib >= 1.4 (and not 1.4.0)

2006-06-05 06:52:44 changed by luks

  • owner changed from rob to luks.
  • status changed from new to assigned.
  • description changed.

(added quoting to the patch in description)

2006-06-25 18:16:00 changed by luks

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [7935]) Corrected sizes of temporary buffers. Patch by urs_fleisch at yahoo dot de. (closes #1563)


Add/Change #1563 (Crash in TRM lookup)




Action