From 5ba9029bc7b387ab0768b051518c5325316c0fdb Mon Sep 17 00:00:00 2001 From: frostb1ten <68353531+frostb1ten@users.noreply.github.com> Date: Mon, 16 Mar 2026 05:07:12 -0500 Subject: [PATCH] Mask *num on entry in deprecated low-level OFB/CFB implementations Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale MergeDate: Wed Mar 18 07:11:44 2026 (Merged from https://github.com/openssl/openssl/pull/30447) --- crypto/bf/bf_cfb64.c | 2 +- crypto/bf/bf_ofb64.c | 2 +- crypto/cast/c_cfb64.c | 2 +- crypto/cast/c_ofb64.c | 2 +- crypto/idea/i_cfb64.c | 2 +- crypto/idea/i_ofb64.c | 2 +- crypto/rc2/rc2cfb64.c | 2 +- crypto/rc2/rc2ofb64.c | 2 +- crypto/rc5/rc5cfb64.c | 2 +- crypto/rc5/rc5ofb64.c | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crypto/bf/bf_cfb64.c b/crypto/bf/bf_cfb64.c index e380972dbdc..cec20b91584 100644 --- a/crypto/bf/bf_cfb64.c +++ b/crypto/bf/bf_cfb64.c @@ -27,7 +27,7 @@ void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec, int *num, int encrypt) { register BF_LONG v0, v1, t; - register int n = *num; + register int n = *num & 0x07; register long l = length; BF_LONG ti[2]; unsigned char *iv, c, cc; diff --git a/crypto/bf/bf_ofb64.c b/crypto/bf/bf_ofb64.c index 5c9193add17..dbd60d18535 100644 --- a/crypto/bf/bf_ofb64.c +++ b/crypto/bf/bf_ofb64.c @@ -26,7 +26,7 @@ void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec, int *num) { register BF_LONG v0, v1, t; - register int n = *num; + register int n = *num & 0x07; register long l = length; unsigned char d[8]; register char *dp; diff --git a/crypto/cast/c_cfb64.c b/crypto/cast/c_cfb64.c index 4170f77a78e..477762005f7 100644 --- a/crypto/cast/c_cfb64.c +++ b/crypto/cast/c_cfb64.c @@ -27,7 +27,7 @@ void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec, int *num, int enc) { register CAST_LONG v0, v1, t; - register int n = *num; + register int n = *num & 0x07; register long l = length; CAST_LONG ti[2]; unsigned char *iv, c, cc; diff --git a/crypto/cast/c_ofb64.c b/crypto/cast/c_ofb64.c index 431446ab5fb..c130f9183fc 100644 --- a/crypto/cast/c_ofb64.c +++ b/crypto/cast/c_ofb64.c @@ -26,7 +26,7 @@ void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec, int *num) { register CAST_LONG v0, v1, t; - register int n = *num; + register int n = *num & 0x07; register long l = length; unsigned char d[8]; register char *dp; diff --git a/crypto/idea/i_cfb64.c b/crypto/idea/i_cfb64.c index c8ed3853285..724905f2f91 100644 --- a/crypto/idea/i_cfb64.c +++ b/crypto/idea/i_cfb64.c @@ -28,7 +28,7 @@ void IDEA_cfb64_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec, int *num, int encrypt) { register unsigned long v0, v1, t; - register int n = *num; + register int n = *num & 0x07; register long l = length; unsigned long ti[2]; unsigned char *iv, c, cc; diff --git a/crypto/idea/i_ofb64.c b/crypto/idea/i_ofb64.c index afa6a960d4e..ed8601ad4f9 100644 --- a/crypto/idea/i_ofb64.c +++ b/crypto/idea/i_ofb64.c @@ -27,7 +27,7 @@ void IDEA_ofb64_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec, int *num) { register unsigned long v0, v1, t; - register int n = *num; + register int n = *num & 0x07; register long l = length; unsigned char d[8]; register char *dp; diff --git a/crypto/rc2/rc2cfb64.c b/crypto/rc2/rc2cfb64.c index ccc69fa6bf8..c0e45787f8c 100644 --- a/crypto/rc2/rc2cfb64.c +++ b/crypto/rc2/rc2cfb64.c @@ -27,7 +27,7 @@ void RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out, int *num, int encrypt) { register unsigned long v0, v1, t; - register int n = *num; + register int n = *num & 0x07; register long l = length; unsigned long ti[2]; unsigned char *iv, c, cc; diff --git a/crypto/rc2/rc2ofb64.c b/crypto/rc2/rc2ofb64.c index b659b72a100..e771ffc3766 100644 --- a/crypto/rc2/rc2ofb64.c +++ b/crypto/rc2/rc2ofb64.c @@ -26,7 +26,7 @@ void RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out, int *num) { register unsigned long v0, v1, t; - register int n = *num; + register int n = *num & 0x07; register long l = length; unsigned char d[8]; register char *dp; diff --git a/crypto/rc5/rc5cfb64.c b/crypto/rc5/rc5cfb64.c index f2f4b9bdfb3..7e3357f039c 100644 --- a/crypto/rc5/rc5cfb64.c +++ b/crypto/rc5/rc5cfb64.c @@ -27,7 +27,7 @@ void RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec, int *num, int encrypt) { register unsigned long v0, v1, t; - register int n = *num; + register int n = *num & 0x07; register long l = length; unsigned long ti[2]; unsigned char *iv, c, cc; diff --git a/crypto/rc5/rc5ofb64.c b/crypto/rc5/rc5ofb64.c index 30487521f22..e55b519956d 100644 --- a/crypto/rc5/rc5ofb64.c +++ b/crypto/rc5/rc5ofb64.c @@ -26,7 +26,7 @@ void RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec, int *num) { register unsigned long v0, v1, t; - register int n = *num; + register int n = *num & 0x07; register long l = length; unsigned char d[8]; register char *dp; -- 2.47.3