From 9aaa36a431df39faca91fb3105a7e4f7b21fdb5d Mon Sep 17 00:00:00 2001 From: Josh Elsasser Date: Thu, 26 Apr 2007 05:40:24 +0000 Subject: [PATCH] Fix a parsing bug which could be triggered by a truncated xml file. --- libtransmission/xml.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libtransmission/xml.c b/libtransmission/xml.c index 514666df3..3e55dc3e3 100644 --- a/libtransmission/xml.c +++ b/libtransmission/xml.c @@ -161,6 +161,7 @@ tr_xmlSkipTag( const char * begin, const char * end ) } else { + CHECKNULL( begin, end, NULL ); overtag( begin, end, &begin ); return begin; } @@ -258,6 +259,7 @@ skipall( const char * begin, const char * end, const char ** afterpos ) static int nexttag( const char * begin, const char * end, const char ** tagpos ) { + *tagpos = NULL; CHECKNULL( begin, end, 0 ); while( end > begin ) @@ -271,15 +273,10 @@ nexttag( const char * begin, const char * end, const char ** tagpos ) { *tagpos = begin; begin++; - if( end > begin ) - { - return ( TAGCLOSE != *begin ); - } - break; + return ( end > begin && TAGCLOSE != *begin ); } } - *tagpos = NULL; return 0; }