diff --git a/librz/crypto/p/crypto_sm4_ecb.c b/librz/crypto/p/crypto_sm4_ecb.c index 7b1b2fbebc0..f85e4ad8beb 100644 --- a/librz/crypto/p/crypto_sm4_ecb.c +++ b/librz/crypto/p/crypto_sm4_ecb.c @@ -185,7 +185,7 @@ static bool update(RzCrypto *cry, const ut8 *buf, int len) { sm4_ecb_encrypt(state->round_keys, len, padded_input, output); if (cry->dir == RZ_CRYPTO_DIR_DECRYPT) { - while (output[len - 1] == 0x0) { + while (len>1 && output[len - 1] == 0x0) { len--; } }