summaryrefslogtreecommitdiff
path: root/lib/version.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-04-22 11:21:24 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-04-22 22:52:32 +0200
commit3fdc4bdb5b00835a1d04cf160cd61fe7f8feb477 (patch)
tree4b2612bf9c8842c82b5a5101b04bf3d1af0d8038 /lib/version.c
parentae15bfc9cecbb71fe60a30934d1f1ffc3520720b (diff)
downloadcurl-3fdc4bdb5b00835a1d04cf160cd61fe7f8feb477.tar.gz
version: skip idn2_check_version() check and add precaution
A gcc-10's -fanalyze complaint made me spot and do these improvements. Closes #5281
Diffstat (limited to 'lib/version.c')
-rw-r--r--lib/version.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/version.c b/lib/version.c
index 47204e881..14e509606 100644
--- a/lib/version.c
+++ b/lib/version.c
@@ -85,12 +85,15 @@ static size_t brotli_version(char *buf, size_t bufsz)
* generate the exact same string and never write any temporary data like
* zeros in the data.
*/
+
+#define VERSION_PARTS 14 /* number of substrings we can concatenate */
+
char *curl_version(void)
{
static char out[300];
char *outp;
size_t outlen;
- const char *src[14];
+ const char *src[VERSION_PARTS];
#ifdef USE_SSL
char ssl_version[200];
#endif
@@ -103,7 +106,7 @@ char *curl_version(void)
#ifdef USE_ARES
char cares_version[40];
#endif
-#if defined(USE_LIBIDN2) || defined(USE_WIN32_IDN)
+#if defined(USE_LIBIDN2)
char idn_version[40];
#endif
#ifdef USE_LIBPSL
@@ -156,14 +159,11 @@ char *curl_version(void)
src[i++] = cares_version;
#endif
#ifdef USE_LIBIDN2
- if(idn2_check_version(IDN2_VERSION)) {
- msnprintf(idn_version, sizeof(idn_version),
- "libidn2/%s", idn2_check_version(NULL));
- src[i++] = idn_version;
- }
-#elif defined(USE_WIN32_IDN)
- msnprintf(idn_version, sizeof(idn_version), "WinIDN");
+ msnprintf(idn_version, sizeof(idn_version),
+ "libidn2/%s", idn2_check_version(NULL));
src[i++] = idn_version;
+#elif defined(USE_WIN32_IDN)
+ src[i++] = (char *)"WinIDN";
#endif
#ifdef USE_LIBPSL
@@ -208,6 +208,8 @@ char *curl_version(void)
}
#endif
+ DEBUGASSERT(i <= VERSION_PARTS);
+
outp = &out[0];
outlen = sizeof(out);
for(j = 0; j < i; j++) {