[Tarantool-patches] [PATCH 2/5] decimal: provide MP_DECIMAL extension serializer
Cyrill Gorcunov
gorcunov at gmail.com
Tue May 12 18:13:24 MSK 2020
On Tue, May 12, 2020 at 01:45:49AM +0200, Vladislav Shpilevoy wrote:
> +
> +int
> +mp_snprint_decimal(char *buf, int size, const char **data, uint32_t len)
> +{
> + decimal_t d;
> + if (decimal_unpack(data, len, &d) == NULL)
> + return -1;
> + return snprintf(buf, size, "%s", decimal_to_string(&d));
> +}
This looks suspicious -- if buffer size is not enough the snprintf
returns not the number of bytes really written but rather a number
of bytes needed to write the desired string. Are you sure it is
safe to return snprintf result here?
More information about the Tarantool-patches
mailing list