From 78c910dc93d8772a0b1af7fc6ae3865e2efdfb3c Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 5 Jul 2015 17:00:11 +0000 Subject: wasteful use of strncpy I never knew that if you give it a small string to copy into a big buffer, it'll waste time filling the rest of it with '\0'. --- src/IO/tls.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/IO/tls.c') diff --git a/src/IO/tls.c b/src/IO/tls.c index c1062c9a..3d14deef 100644 --- a/src/IO/tls.c +++ b/src/IO/tls.c @@ -781,7 +781,7 @@ static void Tls_get_issuer_name(X509 *cert, char *buf, uint_t buflen) if (cert) { X509_NAME_oneline(X509_get_issuer_name(cert), buf, buflen); } else { - strncpy(buf, "(unknown)", buflen); + strcpy(buf, "(unknown)"); buf[buflen-1] = '\0'; } } @@ -796,7 +796,7 @@ static void Tls_get_expiration_str(X509 *cert, char *buf, uint_t buflen) rc = BIO_gets(b, buf, buflen); } if (rc <= 0) { - strncpy(buf, "(unknown)", buflen); + strcpy(buf, "(unknown)"); buf[buflen-1] = '\0'; } BIO_free(b); -- cgit v1.2.3