Port short_read to UBSan
Problem reported by Kirill Furman in: https://lists.gnu.org/r/bug-tar/2025-06/msg00002.html * src/buffer.c (short_read): Use (char *) record_start, instead of record_start->buffer, to avoid undefined behavior accessing past end of buffer. In practice the undefined behavior is harmless unless running with -fsanitize=undefined or a similarly-picky implementation.
This commit is contained in:
1
THANKS
1
THANKS
@@ -308,6 +308,7 @@ Kevin D Quitt drs@netcom.com
|
|||||||
Kevin Dalley kevin@aimnet.com
|
Kevin Dalley kevin@aimnet.com
|
||||||
Kimball Collins kpc@ptolemy.arc.nasa.gov
|
Kimball Collins kpc@ptolemy.arc.nasa.gov
|
||||||
Kimmy Posey kimmyd@bnr.ca
|
Kimmy Posey kimmyd@bnr.ca
|
||||||
|
Kirill Furman kfurman@astralinux.ru
|
||||||
Koji Kishi kis@rqa.sony.co.jp
|
Koji Kishi kis@rqa.sony.co.jp
|
||||||
Konno Hiroharu konno@pac.co.jp
|
Konno Hiroharu konno@pac.co.jp
|
||||||
Kurt Jaeger pi@lf.net
|
Kurt Jaeger pi@lf.net
|
||||||
|
|||||||
@@ -959,11 +959,8 @@ archive_is_dev (void)
|
|||||||
static void
|
static void
|
||||||
short_read (idx_t status)
|
short_read (idx_t status)
|
||||||
{
|
{
|
||||||
idx_t left; /* bytes left */
|
idx_t left = record_size - status; /* bytes left to read */
|
||||||
char *more; /* pointer to next byte to read */
|
char *more = (char *) record_start + status; /* address of next read */
|
||||||
|
|
||||||
more = record_start->buffer + status;
|
|
||||||
left = record_size - status;
|
|
||||||
|
|
||||||
if (left && left % BLOCKSIZE == 0
|
if (left && left % BLOCKSIZE == 0
|
||||||
&& (warning_option & WARN_RECORD_SIZE)
|
&& (warning_option & WARN_RECORD_SIZE)
|
||||||
|
|||||||
Reference in New Issue
Block a user