Merturbation / xar

Automatically exported from code.google.com/p/xar
0 stars 0 forks source link

Undefined behaviour in xar_attrcopy_to_heap if file doesn't have 'archived-checksum' property. #42

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
in io.c (rev188)
in the function xar_attrcopy_to_heap(), around the line 295

    tmpp = xar_prop_pget(p, "archived-checksum");
    if( tmpp )
        csum = xar_prop_getvalue(tmpp);
    tmpf = xmlHashLookup(XAR(x)->csum_hash, BAD_CAST(csum));

if tmpp is null, csum is never initialized, and the call to xmlHashLookup may 
crash.

You should maybe initialize csum to null, and before the call to xmlHashLookup 
(line 298), check 
for csum value, and if null, return an error, or do whatever you want.

Original issue reported on code.google.com by jddu...@gmail.com on 16 Oct 2007 at 7:19

GoogleCodeExporter commented 8 years ago
Thanks.  With commit 189, this should avoid passing an invalid csum to
xmlHashLookup(), it will throw a warning, and will continue with the rest of the
attributes.

Out of curiosity, how did you archive a file without an archived-checksum?

Original comment by bbraun on 16 Oct 2007 at 7:18

GoogleCodeExporter commented 8 years ago
I don' think this case can append in normal condition, but the "if (tmpp)" was 
here, so i assumed that 
"xar_prop_pget(p, "archived-checksum");" could return NULL.

I know, assumptions are evil ;-)

Original comment by jddu...@gmail.com on 17 Oct 2007 at 6:58