• M
    util/uri: URI member path can be null, compare more carfully · afb30dde
    Markus Armbruster 提交于
    uri_resolve_relative() calls strcmp(bas->path, ref->path).  However,
    either argument could be null!  Evidence: the code checks for null
    after the comparison.  Spotted by Coverity.
    
    I suspect this was screwed up when we stole the code from libxml2.
    There the conditional reads
    
        xmlStrEqual((xmlChar *)bas->path, (xmlChar *)ref->path)
    
    with
    
        int
        xmlStrEqual(const xmlChar *str1, const xmlChar *str2) {
    	if (str1 == str2) return(1);
    	if (str1 == NULL) return(0);
    	if (str2 == NULL) return(0);
    	do {
    	    if (*str1++ != *str2) return(0);
    	} while (*str2++);
    	return(1);
        }
    
    Fix by replicating libxml2's logic faithfully.
    
    Cc: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
    Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
    afb30dde
uri.c 54.6 KB