Ticket #290 (new defect)

Opened 8 months ago

[PATCH] keys not written to disk on x86_64

Reported by: tcarter Assigned to: somebody
Priority: major Milestone:
Component: eAccelerator Version: 0.9.5
Keywords: Cc: tcarter@noggin.com.au

Description

On x86_64 CentOS 4 systems objects stored to the cache using eaccelerator_put() are never written out to disk, a similar system using an i386 build has no problems.

The problem comes from the calculation of the path in the eaccelerator_md5() function, in the final call to sprintf() the destination and the source arguments are the same, according to the sprintf man page the results of this are undefined. It seems to work as expected on i386 systems, but on x86_64 systems the path prefix in "s" is overwritten. The following patch resolves the issue by removing the overlap.

--- eaccelerator-0.9.5.2.orig/eaccelerator.c 2007-05-17 03:07:31.000000000 +0800 +++ eaccelerator-0.9.5.2/eaccelerator.c 2007-11-06 15:52:32.000000000 +0800 @@ -421,7 +421,7 @@

s[n++] = '/';

} s[n] = 0;

- snprintf(s, MAXPATHLEN-1, "%s%s%s", s, prefix, md5str); + snprintf(&s[n], MAXPATHLEN-1-n, "%s%s", prefix, md5str);

return 1;

#else

zval retval;

Attachments

eaccelerator-0.9.5.2-md5overlap.diff (382 bytes) - added by tcarter on 11/10/07 03:40:27.
Patch to fix snprintf() overlap problem in eaccelerator_md5() on x86_64

Change History

11/10/07 03:40:27 changed by tcarter

  • attachment eaccelerator-0.9.5.2-md5overlap.diff added.

Patch to fix snprintf() overlap problem in eaccelerator_md5() on x86_64