From nobody Fri Aug 8 22:09:17 2025 X-Original-To: dev-commits-src-all@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 4bzJ8s5bZTz64DLb; Fri, 08 Aug 2025 22:09:17 +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 4bzJ8s2bjvz3rj9; Fri, 08 Aug 2025 22:09:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754690957; 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=T+bwdTC39bbMI/qoTDxO0ckFrzWzNHKTOG0LWwCuwT8=; b=Ofp8swtr4czXBvcFWnzZSOgN990XdiGUbqggv06ZimHUCMeqbKNtaEZ2EyyN8uITRJjAqJ wBzfWa/HPtTD+wacTvOh6D3enG/pHtp7mNCjFGITXUbyCoo6OYPTblIKqrmcgDeiQe9jA7 lL9MF9aU/xTSl66fz0n3mIcD09YMpJnPPGs++LivOgr0gXRW4cVrQcrv3IZHXdU+/CtNmz QfBeEwnD4Pbtrg3vxeQNjfWAguLCOY+fcViDYMQl4AeBjz74EEh2rF42KHeTSWmH1KExWp LrQ1cYsq9fc4SodfPSByupBSzj77dyKdcXxUgbbeP4swz1EjMF8x4cEtorJIgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754690957; 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=T+bwdTC39bbMI/qoTDxO0ckFrzWzNHKTOG0LWwCuwT8=; b=Xb5t2cQn3CZg2qSMwxBLIDtF+pW0TE9lDyi34yscb9ybZwtttyvg+yRWuUQeVDP8NVyiR+ d0bWzU8jFaOaA9Sy22j3Egsz/tt/DWfSi++L8Zk3cJU4if73/SipyjJlSQT3VcV5SqP67Z zsDli2X2MnnktUl5TRRNzQhXY4WCRXs/k9D/Z8NTFut1yJPoF+WuBxhaKknEUyoy72L4X6 S/W3eDahWFRy3ygaFMT/M5Bell97RtA7Z0AAWAGLAfisO74j+K0M/DzpyCr3lsJp2G1IMX w0C226EWhBtWDEKTqw7Rgf1ZHFPhwekRTyQwu+H6uhrNCnd+pp4cR0jwQp9L7Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1754690957; a=rsa-sha256; cv=none; b=utueNpzO6OcnFK+VOmxgnqbXMrcw+fDFJXpmO+2yi4dWaConTosOZQZ4q6lTh1z8LrasVq QJfw9I5XYFnBNfl6VsH8Iy6eY3gqZfNt0ERJRzOmmBvyWBiAzMdStvFMw1ffjIj80NSTiQ he6XmnKlnEt69AwgKNczHuozTbj698xHx/BoxlDg4b6n62hwnG/1V0EuMNUlwp/00WUHUO lp/lquaCQAa1VuO22niLFclRCfYqngVtzcWNwxdPb398fwasjp/R05VXTSOfVZaZFV+uL3 xCFlWtUZHWfcWx7x1WNTxCiCLdybKS7QZAwd0MvGBcaKvimIGVlwb/lSUBoK2A== 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 4bzJ8s1nr0zv0k; Fri, 08 Aug 2025 22:09:17 +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 578M9HYw088982; Fri, 8 Aug 2025 22:09:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 578M9Hck088979; Fri, 8 Aug 2025 22:09:17 GMT (envelope-from git) Date: Fri, 8 Aug 2025 22:09:17 GMT Message-Id: <202508082209.578M9Hck088979@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: 927c3d709317 - stable/14 - kyua: Stop using readdir_r() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 927c3d7093177a9c1f38cf11f59d17a5b41720e8 Auto-Submitted: auto-generated The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=927c3d7093177a9c1f38cf11f59d17a5b41720e8 commit 927c3d7093177a9c1f38cf11f59d17a5b41720e8 Author: Dag-Erling Smørgrav AuthorDate: 2025-08-01 23:11:26 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2025-08-08 19:47:01 +0000 kyua: Stop using readdir_r() It cannot be used safely, and Kyua doesn't even pretend to try. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: igoro Differential Revision: https://reviews.freebsd.org/D51680 (cherry picked from commit 65bae451c23b8d61b2433259d8e707250660eeff) --- contrib/kyua/utils/fs/directory.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/contrib/kyua/utils/fs/directory.cpp b/contrib/kyua/utils/fs/directory.cpp index ff7ad5e34357..9103c2377c34 100644 --- a/contrib/kyua/utils/fs/directory.cpp +++ b/contrib/kyua/utils/fs/directory.cpp @@ -127,16 +127,9 @@ struct utils::fs::detail::directory_iterator::impl : utils::noncopyable { /// not. A null pointer means an invalid iterator. ::DIR* _dirp; - /// Raw representation of the system directory entry. - /// - /// We need to keep this at the class level so that we can use the - /// readdir_r(3) function. - ::dirent _dirent; - /// Custom representation of the directory entry. /// - /// This is separate from _dirent because this is the type we return to the - /// user. We must keep this as a pointer so that we can support the common + /// We must keep this as a pointer so that we can support the common /// operators (* and ->) over iterators. std::auto_ptr< directory_entry > _entry; @@ -192,22 +185,23 @@ struct utils::fs::detail::directory_iterator::impl : utils::noncopyable { /// It is possible to use this function on a new directory_entry object to /// initialize the first entry. /// - /// \throw system_error If the call to readdir_r fails. + /// \throw system_error If the call to readdir fails. void next(void) { ::dirent* result; - if (::readdir_r(_dirp, &_dirent, &result) == -1) { + errno = 0; + if ((result = ::readdir(_dirp)) == NULL && errno != 0) { const int original_errno = errno; - throw fs::system_error(F("readdir_r(%s) failed") % _path, + throw fs::system_error(F("readdir(%s) failed") % _path, original_errno); } if (result == NULL) { _entry.reset(NULL); close(); } else { - _entry.reset(new directory_entry(_dirent.d_name)); + _entry.reset(new directory_entry(result->d_name)); } } };