From a5efc3bbda19d0f8185e190dcc7a7baedf8b80fe Mon Sep 17 00:00:00 2001 From: miod Date: Thu, 17 Apr 2014 19:33:42 +0000 Subject: [PATCH] sprintf: bad. snprintf: good. snprintf with a correct size: better! (harmless in this case) --- lib/libcrypto/asn1/a_strex.c | 2 +- lib/libssl/src/crypto/asn1/a_strex.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libcrypto/asn1/a_strex.c b/lib/libcrypto/asn1/a_strex.c index 713b3cb028e..65f95532a33 100644 --- a/lib/libcrypto/asn1/a_strex.c +++ b/lib/libcrypto/asn1/a_strex.c @@ -149,7 +149,7 @@ static int do_esc_char(unsigned long c, unsigned char flags, char *do_quotes, ch return 2; } if(chflgs & (ASN1_STRFLGS_ESC_CTRL|ASN1_STRFLGS_ESC_MSB)) { - (void) snprintf(tmphex, 11, "\\%02X", chtmp); + (void) snprintf(tmphex, sizeof tmphex, "\\%02X", chtmp); if(!io_ch(arg, tmphex, 3)) return -1; return 3; } diff --git a/lib/libssl/src/crypto/asn1/a_strex.c b/lib/libssl/src/crypto/asn1/a_strex.c index 713b3cb028e..65f95532a33 100644 --- a/lib/libssl/src/crypto/asn1/a_strex.c +++ b/lib/libssl/src/crypto/asn1/a_strex.c @@ -149,7 +149,7 @@ static int do_esc_char(unsigned long c, unsigned char flags, char *do_quotes, ch return 2; } if(chflgs & (ASN1_STRFLGS_ESC_CTRL|ASN1_STRFLGS_ESC_MSB)) { - (void) snprintf(tmphex, 11, "\\%02X", chtmp); + (void) snprintf(tmphex, sizeof tmphex, "\\%02X", chtmp); if(!io_ch(arg, tmphex, 3)) return -1; return 3; } -- 2.20.1