--- clamav-0.92.1~dfsg2/libclamav/petite.c 2007-12-06 07:59:04.000000000 -0500 +++ clamav-0.93.1/libclamav/petite.c 2008-06-04 08:11:11.000000000 -0400 @@ -1,5 +1,7 @@ /* - * Copyright (C) 2004 aCaB + * Copyright (C) 2007-2008 Sourcefire, Inc. + * + * Authors: Alberto Wu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -263,6 +265,7 @@ uint32_t check1, check2; uint8_t mydl = 0; uint8_t goback; + unsigned int q; /* Unpak each original section in turn */ @@ -310,15 +313,18 @@ * (eg the icon): let's fix the rva */ - if (!check4resources) { - unsigned int q; - for ( q = 0 ; q < sectcount ; q++ ) { - if ( thisrva <= sections[q].rva || thisrva >= sections[q].rva + sections[q].vsz) - continue; + for ( q = 0 ; q < sectcount ; q++ ) { + if(!CLI_ISCONTAINED(sections[q].rva, sections[q].vsz, usects[j].rva, usects[j].vsz)) + continue; + if (!check4resources) { usects[j].rva = sections[q].rva; usects[j].rsz = thisrva - sections[q].rva + size; - break; } + break; + } + if (q == sectcount) { + free(usects); + return 1; } /* Increase count of unpacked sections */