summaryrefslogtreecommitdiff
path: root/crypto/property
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2021-05-21 11:19:30 +1000
committerPauli <pauli@openssl.org>2021-05-22 15:30:26 +1000
commit862497a9183412d50615afe2d2bfde1ac6c7ffa8 (patch)
treebd8d249f0cab7c79cb1daeebe136c454d1554bf2 /crypto/property
parentb54611922b5eb760bd64de0c8edfeb13ae81fa65 (diff)
downloadopenssl-new-862497a9183412d50615afe2d2bfde1ac6c7ffa8.tar.gz
property: convert integers to strings properly.
The int64_t type was converted to int (truncation). Negative values were not handled at all. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15396)
Diffstat (limited to 'crypto/property')
-rw-r--r--crypto/property/property_parse.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/crypto/property/property_parse.c b/crypto/property/property_parse.c
index aab8cbe8a4..6352def860 100644
--- a/crypto/property/property_parse.c
+++ b/crypto/property/property_parse.c
@@ -658,11 +658,15 @@ static void put_str(const char *str, char **buf, size_t *remain, size_t *needed)
}
}
-static void put_num(int val, char **buf, size_t *remain, size_t *needed)
+static void put_num(int64_t val, char **buf, size_t *remain, size_t *needed)
{
- int tmpval = val;
+ int64_t tmpval = val;
size_t len = 1;
+ if (tmpval < 0) {
+ len++;
+ tmpval = -tmpval;
+ }
for (; tmpval > 9; len++, tmpval /= 10);
*needed += len;
@@ -670,7 +674,7 @@ static void put_num(int val, char **buf, size_t *remain, size_t *needed)
if (*remain == 0)
return;
- BIO_snprintf(*buf, *remain, "%d", val);
+ BIO_snprintf(*buf, *remain, "%lld", (long long int)val);
if (*remain < len) {
*buf += *remain;
*remain = 0;