From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id B96AF26C18 for ; Tue, 17 Jul 2018 11:15:33 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ootamk9O9KBG for ; Tue, 17 Jul 2018 11:15:33 -0400 (EDT) Received: from smtp43.i.mail.ru (smtp43.i.mail.ru [94.100.177.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 6993126BF5 for ; Tue, 17 Jul 2018 11:15:33 -0400 (EDT) From: Olga Arkhangelskaia Subject: [tarantool-patches] [PATCH 2/2] Added strdup fail checks in say Date: Tue, 17 Jul 2018 18:15:21 +0300 Message-Id: <20180717151521.34679-3-arkholga@tarantool.org> In-Reply-To: <20180717151521.34679-1-arkholga@tarantool.org> References: <20180717151521.34679-1-arkholga@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: Olga Arkhangelskaia Strdup may silently fail without any message from tarantool. Patch adds this checks. v2: there is no v1 for this changes --- src/say.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/say.c b/src/say.c index 501095b3e..d824e778b 100644 --- a/src/say.c +++ b/src/say.c @@ -498,10 +498,21 @@ log_syslog_init(struct log *log, const char *init_str) if (say_parse_syslog_opts(init_str, &opts) < 0) return -1; - if (opts.identity == NULL) + if (opts.identity == NULL) { log->syslog_ident = strdup("tarantool"); - else + if (log->syslog_ident == NULL) { + diag_set(OutOfMemory, strlen("tarantool"), "malloc", + "log->syslog_ident"); + return -1; + } + } else { log->syslog_ident = strdup(opts.identity); + if (log->syslog_ident == NULL) { + diag_set(OutOfMemory, strlen(opts.identity), "malloc", + "log->syslog_ident"); + return -1; + } + } if (opts.facility == syslog_facility_MAX) log->syslog_facility = SYSLOG_LOCAL7; -- 2.14.3 (Apple Git-98)