summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Esser <besser82@fedoraproject.org>2022-11-12 09:19:33 +0100
committerBjörn Esser <besser82@fedoraproject.org>2022-11-12 09:22:49 +0100
commit502c671e9115f147a6316191459afa55ab2f5345 (patch)
tree42dfe599632adc134b38e8b0e93535074f62a399
parenta55d6cd478915ff32e978eb696c43636bc73ccd3 (diff)
downloadlibxcrypt-502c671e9115f147a6316191459afa55ab2f5345.tar.gz
libxcrypt-502c671e9115f147a6316191459afa55ab2f5345.tar.bz2
libxcrypt-502c671e9115f147a6316191459afa55ab2f5345.zip
crypt-des.c: Fix Werror=strict-overflow with GCC 12.x.
Fixes #155 and #163.
-rw-r--r--lib/crypt-des.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/crypt-des.c b/lib/crypt-des.c
index 49272a6..d2e7cd8 100644
--- a/lib/crypt-des.c
+++ b/lib/crypt-des.c
@@ -114,7 +114,7 @@ des_gen_hash (struct des_ctx *ctx, uint32_t count, uint8_t *output,
c1 = *sptr++;
*output++ = ascii64[c1 >> 2];
c1 = (c1 & 0x03) << 4;
- if (sptr >= end)
+ if (end - sptr <= 0)
{
*output++ = ascii64[c1];
break;
@@ -124,7 +124,7 @@ des_gen_hash (struct des_ctx *ctx, uint32_t count, uint8_t *output,
c1 |= c2 >> 4;
*output++ = ascii64[c1];
c1 = (c2 & 0x0f) << 2;
- if (sptr >= end)
+ if (end - sptr <= 0)
{
*output++ = ascii64[c1];
break;
@@ -135,7 +135,7 @@ des_gen_hash (struct des_ctx *ctx, uint32_t count, uint8_t *output,
*output++ = ascii64[c1];
*output++ = ascii64[c2 & 0x3f];
}
- while (sptr < end);
+ while (end - sptr > 0);
*output = '\0';
}
#endif