mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-06-20 03:44:15 +08:00
Fix ZUC out-of-bounds read
This commit is contained in:
11
src/zuc.c
11
src/zuc.c
@@ -325,11 +325,11 @@ void zuc_encrypt(ZUC_STATE *state, const uint8_t *in, size_t inlen, uint8_t *out
|
||||
}
|
||||
LFSR[15] = V;
|
||||
|
||||
// xor with plaintext
|
||||
Z ^= GETU32(in);
|
||||
|
||||
// output ciphertext
|
||||
if (inlen >= 4) {
|
||||
// xor with plaintext
|
||||
Z ^= GETU32(in);
|
||||
|
||||
PUTU32(out, Z);
|
||||
inlen -= 4;
|
||||
in += 4;
|
||||
@@ -338,6 +338,11 @@ void zuc_encrypt(ZUC_STATE *state, const uint8_t *in, size_t inlen, uint8_t *out
|
||||
uint8_t word[4];
|
||||
size_t i;
|
||||
|
||||
memcpy(word, in, inlen);
|
||||
|
||||
// xor with plaintext
|
||||
Z ^= GETU32(word);
|
||||
|
||||
PUTU32(word, Z);
|
||||
for (i = 0; i < inlen; i++) {
|
||||
out[i] = word[i];
|
||||
|
||||
Reference in New Issue
Block a user