summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorphintuka <phintuka>2009-08-18 10:35:45 +0000
committerphintuka <phintuka>2009-08-18 10:35:45 +0000
commit9cf764d335519ce8d03764cfe984697e7ab1dccd (patch)
tree63dc4ef22e9530dfd305816ce75036b8ae3bed02 /tools
parenta802ada1375305a88e087e26d7d4200efed77f4f (diff)
downloadxineliboutput-9cf764d335519ce8d03764cfe984697e7ab1dccd.tar.gz
xineliboutput-9cf764d335519ce8d03764cfe984697e7ab1dccd.tar.bz2
Fixed buffer overflow.
Removed redundant strdup.
Diffstat (limited to 'tools')
-rw-r--r--tools/metainfo_menu.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/tools/metainfo_menu.c b/tools/metainfo_menu.c
index 01d97f30..4a31b18c 100644
--- a/tools/metainfo_menu.c
+++ b/tools/metainfo_menu.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: metainfo_menu.c,v 1.7 2008-11-20 15:44:37 phintuka Exp $
+ * $Id: metainfo_menu.c,v 1.8 2009-08-18 10:35:45 phintuka Exp $
*
*/
@@ -21,6 +21,7 @@
#include "metainfo_menu.h"
+
//
// cMetainfoMenu
//
@@ -41,6 +42,7 @@ cMetainfoMenu::~cMetainfoMenu()
void cMetainfoMenu::Display(void)
{
cOsdMenu::Display();
+
char metadata[4096];
metadata[0] = 0;
@@ -53,16 +55,17 @@ void cMetainfoMenu::Display(void)
md_list = EXTRACTOR_removeDuplicateKeywords(md_list, 0);
md_list = EXTRACTOR_removeKeywordsOfType(md_list, EXTRACTOR_THUMBNAILS);
- const char *key;
- char * buf;
+ uint pos = 0;
+ int n;
while(md_list) {
- if((key=EXTRACTOR_getKeywordTypeAsString(md_list->keywordType))) {
- buf = strdup(md_list->keyword);
- sprintf(metadata, "%s%s: %s\n", metadata, key, buf);
- free(buf);
- }
- md_list=md_list->next;
- }
+ const char *key = EXTRACTOR_getKeywordTypeAsString(md_list->keywordType);
+ if(key && pos < sizeof(metadata))
+ if(0 < (n = snprintf(metadata+pos, sizeof(metadata)-pos, "%s: %s\n", key, md_list->keyword)))
+ pos += n;
+ md_list = md_list->next;
+ }
+ metadata[sizeof(metadata)-1] = 0;
+
EXTRACTOR_freeKeywords(md_list);
EXTRACTOR_removeAll(plugins); /* unload plugins */
#else