Skip to content

Commit 3a0c3a1

Browse files
committed
removed check for n > 0x7fffffff, add negative value check
1 parent d6c8e7b commit 3a0c3a1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

wolfcrypt/src/hpke.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ static int I2OSP(int n, int w, byte* out)
101101
{
102102
int i;
103103

104-
if (w <= 0 || w > 32) {
104+
if (w <= 0 || w > 32 || n < 0) {
105105
return MP_VAL;
106106
}
107107

108108
/* if width is less than int max check that n is less than w bytes max */
109109
/* if width is greater than int max check that n is less than int max */
110-
if ((w < 4 && n > ((1 << (w * 8)) - 1)) || (w >= 4 && n > 0x7fffffff)) {
110+
if ((w < 4 && n > ((1 << (w * 8)) - 1))) {
111111
return MP_VAL;
112112
}
113113

0 commit comments

Comments
 (0)