Add check for all zeros in CreateMpint

pull/925/head
Paul Adelsbach 2026-04-20 16:26:42 -07:00 committed by John Safranek
parent b007310fa2
commit 0d283d2dd3
1 changed files with 7 additions and 0 deletions

View File

@ -4636,6 +4636,13 @@ static int CreateMpint(byte* buf, word32* sz, byte* pad)
if (buf[i] != 0x00)
break;
}
/* all-zero buffer encodes as empty mpint per RFC 4251 */
if (i == *sz) {
*pad = 0;
*sz = 0;
return WS_SUCCESS;
}
*pad = (buf[i] & 0x80) ? 1 : 0;
/* if padding would be needed and have leading 0's already then do not add