diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-01-15 10:21:36 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-01-18 09:41:32 +0100 |
commit | 0b33310cd02aa8e33b2fc1613d13cadb83bb7da8 (patch) | |
tree | e9e519a2f28dd04a7d69f8927a91193257eeabda /libavcodec/bitstream.h | |
parent | bf23d530d25370819792378d72979a137e6527b9 (diff) | |
download | ffmpeg-0b33310cd02aa8e33b2fc1613d13cadb83bb7da8.tar.gz |
lavc/bitstream: avoid UB in bits_{read,peek}_signed(0)
bits_*_signed(0) will currently invoke an undefined shift by
8 * sizeof(int).
Add bits_*_signed_nz() that only works for n>0, analogous to
bits_read_nz(). Add an explicit check for n=0 in bits_*_signed().
Found-by: James Almer
Diffstat (limited to 'libavcodec/bitstream.h')
-rw-r--r-- | libavcodec/bitstream.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libavcodec/bitstream.h b/libavcodec/bitstream.h index ef7d8d55c2..b60f0c296d 100644 --- a/libavcodec/bitstream.h +++ b/libavcodec/bitstream.h @@ -89,9 +89,11 @@ # define bits_read_63 bits_read_63_le # define bits_read_64 bits_read_64_le # define bits_read_signed bits_read_signed_le +# define bits_read_signed_nz bits_read_signed_nz_le # define bits_peek_nz bits_peek_nz_le # define bits_peek bits_peek_le # define bits_peek_signed bits_peek_signed_le +# define bits_peek_signed_nz bits_peek_signed_nz_le # define bits_skip bits_skip_le # define bits_seek bits_seek_le # define bits_align bits_align_le @@ -115,9 +117,11 @@ # define bits_read_63 bits_read_63_be # define bits_read_64 bits_read_64_be # define bits_read_signed bits_read_signed_be +# define bits_read_signed_nz bits_read_signed_nz_be # define bits_peek_nz bits_peek_nz_be # define bits_peek bits_peek_be # define bits_peek_signed bits_peek_signed_be +# define bits_peek_signed_nz bits_peek_signed_nz_be # define bits_skip bits_skip_be # define bits_seek bits_seek_be # define bits_align bits_align_be |