Skip to content

Commit 5da6aac

Browse files
committed
Add check for all zeros in CreateMpint
1 parent 2568b26 commit 5da6aac

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/internal.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4636,6 +4636,13 @@ static int CreateMpint(byte* buf, word32* sz, byte* pad)
46364636
if (buf[i] != 0x00)
46374637
break;
46384638
}
4639+
/* all-zero buffer encodes as empty mpint per RFC 4251 */
4640+
if (i == *sz) {
4641+
*pad = 0;
4642+
*sz = 0;
4643+
return WS_SUCCESS;
4644+
}
4645+
46394646
*pad = (buf[i] & 0x80) ? 1 : 0;
46404647

46414648
/* if padding would be needed and have leading 0's already then do not add

0 commit comments

Comments
 (0)