summaryrefslogtreecommitdiff
path: root/multimedia/MPlayer/stream_cddb_fix_20080120.diff
blob: 461d11c854b57ad9ae6cc0508f6cbe1889697926 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
diff -Nur MPlayer-1.0rc2.orig/stream/stream_cddb.c MPlayer-1.0rc2/stream/stream_cddb.c
--- MPlayer-1.0rc2.orig/stream/stream_cddb.c	2007-10-07 14:49:26.000000000 -0500
+++ MPlayer-1.0rc2/stream/stream_cddb.c	2008-02-01 10:06:49.913021939 -0600
@@ -53,6 +53,7 @@
 #include "version.h"
 #include "stream.h"
 #include "network.h"
+#include "libavutil/intreadwrite.h"
 
 #define DEFAULT_FREEDB_SERVER	"freedb.freedb.org"
 #define DEFAULT_CACHE_DIR	"/.cddb/"
@@ -453,8 +454,9 @@
 		} else {
 			len = ptr2-ptr+1;
 		}
+		len = FFMIN(sizeof(album_title) - 1, len);
 		strncpy(album_title, ptr, len);
-		album_title[len-2]='\0';
+		album_title[len]='\0';
 	}
 	mp_msg(MSGT_DEMUX, MSGL_STATUS, MSGTR_MPDEMUX_CDDB_ParseOKFoundAlbumTitle, album_title);
 	return 0;
@@ -490,8 +492,9 @@
 				} else {
 					len = ptr2-ptr+1;
 				}
+				len = FFMIN(sizeof(album_title) - 1, len);
 				strncpy(album_title, ptr, len);
-				album_title[len-2]='\0';
+				album_title[len]='\0';
 			}
 			mp_msg(MSGT_DEMUX, MSGL_STATUS, MSGTR_MPDEMUX_CDDB_ParseOKFoundAlbumTitle, album_title);
 			return cddb_request_titles(cddb_data);