segfault in file-4.17

Mike Frysinger vapier at gentoo.org
Tue Mar 14 01:40:53 EET 2006


seems i missed this in the earlier request for testing since i only tested 
amd64, sorry :/

on Gentoo/x86 systems, a bunch of users have been hitting segfaults when 
compiling the magic files during build (Bug 126012):
../src/file -C -m magic
make[2]: *** [magic.mgc] Segmentation fault

the crash appears to be in libmagic.so as using `file` 4.16 but libgmagic.so 
from 4.17 also crashes ... looking through the 4.16 and 4.17 diff, i noticed 
this change in the apprentice_file() func in src/apprentice.c:
         maxmagic = MAXMAGIS;
-	*magicp = (struct magic *) calloc(maxmagic, sizeof(struct magic));
-	if (*magicp == NULL) {
+	if ((marray = malloc(maxmagic * sizeof(*marray))) == NULL) {
 		(void)fclose(f);

i dont know whether this change was on purpose, but reverting it does fix the 
crash for me ... in the attached patch, i also removed an unused variable
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-init-mem.patch
Type: text/x-diff
Size: 581 bytes
Desc: not available
Url : http://mx.gw.com/pipermail/file/attachments/20060314/602b4c38/attachment.bin 


More information about the File mailing list