Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove OPJ_NOSANITIZE in opj_bio_read() and opj_bio_write() (#761) #955

Merged
merged 1 commit into from
Jun 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/lib/openjp2/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,19 @@ void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len)
bio->ct = 0;
}

OPJ_NOSANITIZE("unsigned-integer-overflow")
void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n)
{
OPJ_UINT32 i;
OPJ_INT32 i;

assert((n > 0U) && (n <= 32U));
for (i = n - 1; i < n; i--) { /* overflow used for end-loop condition */
for (i = (OPJ_INT32)n - 1; i >= 0; i--) {
opj_bio_putbit(bio, (v >> i) & 1);
}
}

OPJ_NOSANITIZE("unsigned-integer-overflow")
OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n)
{
OPJ_UINT32 i;
OPJ_INT32 i;
OPJ_UINT32 v;

assert((n > 0U) /* && (n <= 32U)*/);
Expand All @@ -187,7 +185,7 @@ OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n)
assert(n <= 32U);
#endif
v = 0U;
for (i = n - 1; i < n; i--) { /* overflow used for end-loop condition */
for (i = (OPJ_INT32)n - 1; i >= 0; i--) {
v |= opj_bio_getbit(bio) <<
i; /* can't overflow, opj_bio_getbit returns 0 or 1 */
}
Expand Down