mirror of
https://github.com/iputils/iputils.git
synced 2026-02-07 22:50:40 +08:00
The outbuf in struct ping_rts is used as a buffer for composing outgoing packets, the problem was that it was accessed in larger chunks than a byte but at the same time the buffer is defined as an array of bytes, hence the memory alignment was not guaranteed. This was found on SPARC where ping crashed with SIGBUS when attempting to call gettimeofday() with a pointer inside of the outbuf buffer. There are many more cases in the code where we access the array by a larger than byte quantities that were working fine only by a chance as most of the time the outpack buffer was accidentally aligned to four byte boundary (since the start of the structure has to be aligned for 64bit on 64bit machine and the array is preceeded by 32bit integer). The proper solution is to add the aligned attribute to the array, which forces the start of the outpack array to be aligned to the largest data type used on the targed machine. Fixes: https://github.com/iputils/iputils/issues/598 Closes: https://github.com/iputils/iputils/pull/600 Signed-off-by: Cyril Hrubis <chrubis@suse.cz> Reported-by: Stian Halseth <stian@itx.no> Tested-by: Stian Halseth <stian@itx.no> Reviewed-by: Petr Vorel <pvorel@suse.cz>