aboutsummaryrefslogtreecommitdiffstats
path: root/community/minidlna/10-minidlna-nfo.patch
blob: fd0049faa15bd083199aadbbed3cd988cc84c74b (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
34
35
36
37
38
39
40
41
42
43
44
https://sourceforge.net/p/minidlna/bugs/294/

--- a/metadata.c
+++ b/metadata.c
@@ -160,7 +160,7 @@
 parse_nfo(const char *path, metadata_t *m)
 {
 	FILE *nfo;
-	char buf[65536];
+	char *buf;
 	struct NameValueParserData xml;
 	struct stat file;
 	size_t nread;
@@ -172,11 +172,13 @@
 		DPRINTF(E_INFO, L_METADATA, "Not parsing very large .nfo file %s\n", path);
 		return;
 	}
+	buf = malloc(file.st_size+1);
+	memset(buf, '\0', file.st_size+1);
 	DPRINTF(E_DEBUG, L_METADATA, "Parsing .nfo file: %s\n", path);
 	nfo = fopen(path, "r");
 	if( !nfo )
 		return;
-	nread = fread(&buf, 1, sizeof(buf), nfo);
+	nread = fread(buf, 1, file.st_size, nfo);
 	
 	ParseNameValue(buf, nread, &xml, 0);
 
@@ -230,6 +232,7 @@
 
 	ClearNameValueList(&xml);
 	fclose(nfo);
+	free(buf);
 }
 
 void
@@ -676,6 +679,7 @@
 
 	memset(&m, '\0', sizeof(m));
 	memset(&video, '\0', sizeof(video));
+	memset(nfo, '\0', sizeof(nfo));
 
 	//DEBUG DPRINTF(E_DEBUG, L_METADATA, "Parsing video %s...\n", name);
 	if ( stat(path, &file) != 0 )