Skip to content

Commit

Permalink
Fix CID 1584213 (Unsigned compared against 0)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Mar 5, 2024
1 parent 0442786 commit 61c09b2
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/jp2kio.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ OpjBuffer buffer;
*---------------------------------------------------------------------*/
static OPJ_SIZE_T
opj_read_from_buffer(void *p_buffer, OPJ_SIZE_T p_nb_bytes, OpjBuffer *pbuf) {
if (pbuf->pos < 0 || pbuf->pos > pbuf->len)
if (pbuf->pos > pbuf->len)
return (OPJ_SIZE_T) - 1;

OPJ_SIZE_T l_nb_read = pbuf->len - pbuf->pos;
Expand All @@ -985,9 +985,6 @@ opj_read_from_buffer(void *p_buffer, OPJ_SIZE_T p_nb_bytes, OpjBuffer *pbuf) {
static OPJ_SIZE_T
opj_write_from_buffer(const void *p_buffer, OPJ_SIZE_T p_nb_bytes,
OpjBuffer *pbuf) {
if (pbuf->pos < 0)
return 0;

size_t newpos = pbuf->pos + p_nb_bytes;
if (newpos > pbuf->size) {
size_t oldsize = pbuf->size;
Expand Down

0 comments on commit 61c09b2

Please sign in to comment.