From nobody Fri Jul 25 09:23:23 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4bpMqb2HcVz62vB5; Fri, 25 Jul 2025 09:23:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bpMqb1JkZz44t5; Fri, 25 Jul 2025 09:23:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753435403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FraJIN7VkjSVlemxLwnWMn+O8yfbaLPi7Md7Yfd2aVw=; b=iv804mWlV+D0orZvS7uvshqsRj3Hzm96M6zUnpKT0vfkb4UwlZsvkyZUooeQEgfRD6uW5h YJnldbY67dGAWEoSS/bVxWSrdNhMRgTT6KgBdPFM4bt5EHWBDRIovMBwrHqqIbXBcf9+l3 Dc4FxTPeeJtAnPiRT19JyUTTcDZXfg76msRmT3JIihvsosiv2/4jiA/ZoQfIVm/CtK85OY e5jXO3L8YSkDVMdcM217mOifDx/NTUv2pDKsqIpKwv3do3bGol1U6C/+/FM4PcFuwxZmIz /dvTREwHVYErEot4xc4qKxfQtl5sr1Pbu8MPXFWpJvryDlFuZsn5ZAXiOjJwjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753435403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FraJIN7VkjSVlemxLwnWMn+O8yfbaLPi7Md7Yfd2aVw=; b=cB2mkT2UVyJPhIjmtTpZo6zY7+ElAe4FeGM8fiuAz02EM/y+8qz5lnWP7p3uZftxcr1xWA L7XRvGZ4DxZtME3RbBOhy7oHLIVpujNImIM4NsLQCCNqMTGSZZUdntCEwb4xLbmkHNAKWk BCCoMmnplthLXFJiKOubkj2flMLZsUd4mglv9ibKf9HJiHi2PaztJlaPGlZRfI5A7Y+OUB p9ixsIY9CPngtlW/+FN371ifCOiesCI5pY8K8vp5+M0ofKsMww8Gjn/MleYusiqjA/oDrp duO8mt3b1TeusNdpkRSRVKNECqSUmCEStUoHTMbx6fBLBFPyGhqT2ebNY31fEA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1753435403; a=rsa-sha256; cv=none; b=OtYUVj/U7RzwfJy80ooxrA8l/rkDp6w+UUT1xn0V7p93/mkIGB7QullliZsPsDQwk3RpQw bNxpJUDMFKGJczw3Aafn2aT1SNRvhlxAEAW8dtdDiVWSiKdWtywD+uBreRoc86jN9kOQma FCv8NfVgtNCWxWRgowjHjVT1hQMxkh1+ubV51RJ7pabAUwmMfrPiKYPRnv/8CTeVkcidgj Rr0GmNiLbpI8OG6hKC0OaofNv7dBl/XdDfs0YiHLQUKUb4VRxQHHTtQJfyDnSAUzVwkPSa sNb2dx4zKwyZ9/gYoS68OTuFmyqY41wJLJ8HHgFv27hlMHBO8FYbh1sSxNtgJw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4bpMqb0nq8zfWT; Fri, 25 Jul 2025 09:23:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 56P9NNjf092089; Fri, 25 Jul 2025 09:23:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56P9NNxm092086; Fri, 25 Jul 2025 09:23:23 GMT (envelope-from git) Date: Fri, 25 Jul 2025 09:23:23 GMT Message-Id: <202507250923.56P9NNxm092086@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Bojan =?utf-8?Q?Novkovi=C4=87?= Subject: git: 108e2d1137aa - main - db/hash.c: Do not return an error when opening a missing database with O_CREAT List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bnovkov X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 108e2d1137aabc65db3cff545615e9e8927dbe23 Auto-Submitted: auto-generated The branch main has been updated by bnovkov: URL: https://cgit.FreeBSD.org/src/commit/?id=108e2d1137aabc65db3cff545615e9e8927dbe23 commit 108e2d1137aabc65db3cff545615e9e8927dbe23 Author: Bojan Novković AuthorDate: 2025-07-24 15:07:34 +0000 Commit: Bojan Novković CommitDate: 2025-07-25 09:22:44 +0000 db/hash.c: Do not return an error when opening a missing database with O_CREAT dbm_open currently returns an error when opening a missing database with O_CREAT but creates the request database file. This is caused by a buggy check in __hash_open which attempts to detect a new (or empty) database file, but fails to take the O_CREAT flag into account. Fix this by expanding the check to include O_CREAT. Fixes: edcdc752ecdd Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D51491 --- lib/libc/db/hash/hash.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index 7a66f5443d94..cc96fb5ce326 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -120,7 +120,8 @@ __hash_open(const char *file, int flags, int mode, if ((hashp->fp = _open(file, flags | O_CLOEXEC, mode)) == -1) RETURN_ERROR(errno, error0); new_table = _fstat(hashp->fp, &statbuf) == 0 && - statbuf.st_size == 0 && (flags & O_ACCMODE) != O_RDONLY; + statbuf.st_size == 0 && + ((flags & O_ACCMODE) != O_RDONLY || (flags & O_CREAT) != 0); } else new_table = 1;