From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [94.100.177.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 1054645C304 for ; Fri, 11 Dec 2020 17:50:13 +0300 (MSK) From: Leonid Vasiliev Date: Fri, 11 Dec 2020 17:49:10 +0300 Message-Id: <09684330fa61f01381f05bbbc0e49e567a8a14a7.1607696813.git.lvasiliev@tarantool.org> In-Reply-To: References: In-Reply-To: References: Subject: [Tarantool-patches] [PATCH v2 1/3] sql: add missing diag_set on failure when working with files inside SQL module List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: v.shpilevoy@tarantool.org, imeevma@tarantool.org, korablev@tarantool.org, sergos@tarantool.org, m.semkin@corp.mail.ru Cc: Mergen Imeev , tarantool-patches@dev.tarantool.org From: Mergen Imeev SQL module didn't set an error in the diagnostics area on a file operation failure. This could lead to a crash like in #5537. Part of #5537 --- src/box/sql/os_unix.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/box/sql/os_unix.c b/src/box/sql/os_unix.c index b351c55..557d709 100644 --- a/src/box/sql/os_unix.c +++ b/src/box/sql/os_unix.c @@ -159,14 +159,17 @@ robust_open(const char *z, int f, mode_t m) if (fd < 0) { if (errno == EINTR) continue; + diag_set(SystemError, strerror(errno)); break; } if (fd >= SQL_MINIMUM_FILE_DESCRIPTOR) break; close(fd); fd = -1; - if (open("/dev/null", f, m) < 0) + if (open("/dev/null", f, m) < 0) { + diag_set(SystemError, strerror(errno)); break; + } } if (fd >= 0) { if (m != 0) { @@ -831,8 +834,10 @@ seekAndWriteFd(int fd, /* File descriptor to write to */ rc = write(fd, pBuf, nBuf); } while (rc < 0 && errno == EINTR); - if (rc < 0) + if (rc < 0) { + diag_set(SystemError, strerror(errno)); *piErrno = errno; + } return rc; } -- 2.7.4