From: Ian Jackson Date: Wed, 10 Dec 2014 23:16:37 +0000 (+0000) Subject: Fix for malicious optimisation of memcpy in test suite, which causes failure with... X-Git-Tag: adns-1.5.1~14 X-Git-Url: https://git.distorted.org.uk/~mdw/adns/commitdiff_plain/d8fa191ed7774818862febd6ade774cb7e149ab9 Fix for malicious optimisation of memcpy in test suite, which causes failure with gcc-4.1.9 -O3. See Debian bug #772718. --- diff --git a/changelog b/changelog index a3e7dbb..fedd31a 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,8 @@ adns (1.5.1~~) unstable; urgency=low * Portability fix for systems where socklen_t is bigger than int. + * Fix for malicious optimisation of memcpy in test suite, which + causes failure with gcc-4.1.9 -O3. See Debian bug #772718. -- diff --git a/regress/hcommon.c b/regress/hcommon.c index ebbef94..e63a8cd 100644 --- a/regress/hcommon.c +++ b/regress/hcommon.c @@ -281,7 +281,7 @@ void *Hrealloc(void *op, size_t nsz) { size_t osz; if (op) { oldnode= (void*)((char*)op - MALLOCHSZ); osz= oldnode->sz; } else { osz= 0; } np= Hmalloc(nsz); - memcpy(np,op, osz>nsz ? nsz : osz); + if (osz) memcpy(np,op, osz>nsz ? nsz : osz); Hfree(op); return np; } diff --git a/regress/hcommon.c.m4 b/regress/hcommon.c.m4 index c5069ee..330da4d 100644 --- a/regress/hcommon.c.m4 +++ b/regress/hcommon.c.m4 @@ -301,7 +301,7 @@ void *Hrealloc(void *op, size_t nsz) { if (op) { oldnode= (void*)((char*)op - MALLOCHSZ); osz= oldnode->sz; } else { osz= 0; } np= Hmalloc(nsz); - memcpy(np,op, osz>nsz ? nsz : osz); + if (osz) memcpy(np,op, osz>nsz ? nsz : osz); Hfree(op); return np; }