First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 12208
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: SpanKY <vapier@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: Sam Yates <sam@quux.dropbear.id.au>
Add CC:
CC:
URL:
Summary:
Status Whiteboard:
Keywords:

Filename Description Type Creator Created Size Actions
libcdaudio-0.99.6-fprintf+errorret.patch Fixes wrong fprintf() call, plus some error checks. patch Sam Yates 2002-12-16 16:33 0000 987 bytes Details | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 12208 depends on: Show dependency tree
Bug 12208 blocks: 12210
Votes: 0    Show votes for this bug    Vote for this bug

Additional Comments: (this is where you put emerge --info)


Not eligible to see or edit group visibility for this bug.






View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2002-12-15 12:25 0000
In libcdaudio-0.99.6, cddb.c there is the line

fprintf(stdout, "%*s\n", index, index, inbuffer);

which is just wrong, and can (and has) caused segfaults.
Fixed in patch to libcdaudio below, along with a couple of
error checks - one of which did cause cdcd to display garbage
instead of an error message.

--- libcdaudio-0.99.6/source/cddb.c     2001-08-18 16:26:19.000000000 +0200
+++ libcdaudio-0.99.6-patched/source/cddb.c     2002-12-15 18:29:26.000000000 +0100
@@ -840,7 +840,7 @@
     inbuffer[index] = inchar;
   }
   
-  fprintf(stdout, "%*s\n", index, index, inbuffer); 
+  fprintf(stdout, "%*s\n", index, inbuffer); 
   return index;
 }
 
@@ -916,7 +916,7 @@
   free(outbuffer);
    
   if(mode == CDDB_MODE_HTTP)
-    cddb_skip_http_header(sock);
+    if (cddb_skip_http_header(sock)<0) return -1;
 
   if((inbuffer = malloc(256)) == NULL)
     return -1;
@@ -1160,11 +1160,13 @@
             cddb_genre(entry->entry_genre),
             entry->entry_id);
        
-  send(sock, outbuffer, strlen(outbuffer), 0);
+  if (send(sock, outbuffer, strlen(outbuffer), 0)<0)
+    return -1;
+
   free(outbuffer);
    
   if(mode == CDDB_MODE_HTTP)
-    cddb_skip_http_header(sock);
+    if (cddb_skip_http_header(sock)<0) return -1;
 
   if(cddb_read_token(sock, token) < 0)
     return -1;

------- Comment #1 From SpanKY 2002-12-15 12:27:59 0000 -------
-  send(sock, outbuffer, strlen(outbuffer), 0); 
+  if (send(sock, outbuffer, strlen(outbuffer), 0)<0) 
+    return -1; 
+ 
   free(outbuffer); 
 
wouldnt it be better to save the return value, free the buffer, then check the return 
value ?  as it is it looks like you just generated a memleak 

------- Comment #2 From Sam Yates 2002-12-15 15:26:43 0000 -------
Yes, you're perfectly correct!

Could you pretend I got it right the first time? :)

------- Comment #3 From SpanKY 2002-12-16 13:02:14 0000 -------
could you please post said patch as an attachement ?

when you post it as a comment the whitespace gets all screwed up making the
patch invalid ...

------- Comment #4 From Sam Yates 2002-12-16 16:33:51 0000 -------
Created an attachment (id=6549) [edit]
Fixes wrong fprintf() call, plus some error checks.

Patch attached - hopefully without memleaks this time!

------- Comment #5 From SpanKY 2002-12-16 18:41:15 0000 -------
all set now, thx for the patch

http://cvs.gentoo.org/cgi-bin/viewcvs.cgi/gentoo-x86/media-libs/libcdaudio/files/libcdaudio-0.99.6-sanity-checks.patch?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.gentoo.org/cgi-bin/viewcvs.cgi/gentoo-x86/media-libs/libcdaudio/libcdaudio-0.99.6-r1.ebuild?rev=1.1&content-type=text/vnd.viewcvs-markup

First Last Prev Next    No search results available      Search page      Enter new bug