diff options
author | Phil Sutter <phil@nwl.cc> | 2021-03-10 14:38:37 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2021-11-30 14:57:46 +0100 |
commit | 00c35de933e95385acbe7fdc8aaab5a697f734a5 (patch) | |
tree | 8c2e34e73a54c6fda9451034226dbcf6eb389632 /src | |
parent | 4e1abfc552170d6db5c511634a29918e64c1b51b (diff) |
datatype: Fix size of time_type
Used by 'ct expiration', time_type is supposed to be 32bits. Passing a
64bits variable to constant_expr_alloc() causes the value to be always
zero on Big Endian.
Fixes: 0974fa84f162a ("datatype: seperate time parsing/printing from time_type")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'src')
-rw-r--r-- | src/datatype.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/datatype.c b/src/datatype.c index a06c3996..b2e667ce 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -1068,6 +1068,7 @@ static struct error_record *time_type_parse(struct parse_ctx *ctx, struct expr **res) { struct error_record *erec; + uint32_t s32; uint64_t s; erec = time_parse(&sym->location, sym->identifier, &s); @@ -1077,9 +1078,10 @@ static struct error_record *time_type_parse(struct parse_ctx *ctx, if (s > UINT32_MAX) return error(&sym->location, "value too large"); + s32 = s; *res = constant_expr_alloc(&sym->location, &time_type, BYTEORDER_HOST_ENDIAN, - sizeof(uint32_t) * BITS_PER_BYTE, &s); + sizeof(uint32_t) * BITS_PER_BYTE, &s32); return NULL; } @@ -1088,7 +1090,7 @@ const struct datatype time_type = { .name = "time", .desc = "relative time", .byteorder = BYTEORDER_HOST_ENDIAN, - .size = 8 * BITS_PER_BYTE, + .size = 4 * BITS_PER_BYTE, .basetype = &integer_type, .print = time_type_print, .json = time_type_json, |