From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 15717469710 for ; Tue, 12 May 2020 18:13:29 +0300 (MSK) Received: by mail-lf1-f68.google.com with SMTP id x73so10887566lfa.2 for ; Tue, 12 May 2020 08:13:28 -0700 (PDT) Date: Tue, 12 May 2020 18:13:24 +0300 From: Cyrill Gorcunov Message-ID: <20200512151324.GA2219@grain> References: <449685df941ca9a14e102738da413e737e559aea.1589240704.git.v.shpilevoy@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <449685df941ca9a14e102738da413e737e559aea.1589240704.git.v.shpilevoy@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH 2/5] decimal: provide MP_DECIMAL extension serializer List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org 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?