From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id ACB88385772C; Fri, 16 Jun 2023 19:47:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ACB88385772C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1686944874; bh=maA9Dja7fe+KP52SBR4ojCce5YqFVu5WXFIv6bjLQdU=; h=From:To:Subject:Date:From; b=JPHy7FeTnHiB6k8KdLM1ChMm6+bHDY6Oe6WcoTLj1FoUOt5WuDfS5liApMMDCJYPF 4LA6v7p3we7TV3MIrMlOEyiKFtrLgV28jiIRB3fQeBMwZltFo/jf2qCxfbL3odJpjI kTHvQiZ6gnuCacyFloQqEjDXhN31ntVANm39khRE= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: use new XATTR_{NAME,SIZE}_MAX instead of MAX_EA_{NAME,VALUE}_LEN X-Act-Checkin: newlib-cygwin X-Git-Author: Philippe Cerfon X-Git-Refname: refs/heads/main X-Git-Oldrev: 538b29a8da8661eceab9b7329d24625256a8d469 X-Git-Newrev: 048031501043e61ca31713b92ce2190213c7fb21 Message-Id: <20230616194754.ACB88385772C@sourceware.org> Date: Fri, 16 Jun 2023 19:47:54 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D04803150104= 3e61ca31713b92ce2190213c7fb21 commit 048031501043e61ca31713b92ce2190213c7fb21 Author: Philippe Cerfon AuthorDate: Tue Jun 6 02:52:49 2023 +0200 Commit: Corinna Vinschen CommitDate: Fri Jun 16 21:44:41 2023 +0200 Cygwin: use new XATTR_{NAME,SIZE}_MAX instead of MAX_EA_{NAME,VALUE}_LEN =20 Signed-off-by: Philippe Cerfon Diff: --- winsup/cygwin/ntea.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/winsup/cygwin/ntea.cc b/winsup/cygwin/ntea.cc index a400fcb2b302..70815649c374 100644 --- a/winsup/cygwin/ntea.cc +++ b/winsup/cygwin/ntea.cc @@ -17,9 +17,11 @@ details. */ #include "tls_pbuf.h" #include #include +#include =20 -#define MAX_EA_NAME_LEN 256 -#define MAX_EA_VALUE_LEN 65536 +/* On storage the `user.` prefix is not included but the terminating null = byte + is needed.*/ +#define _XATTR_NAME_MAX_ONDISK_ (XATTR_NAME_MAX - strlen("user.") + 1) =20 /* At least one maximum sized entry fits. CV 2014-04-04: NtQueryEaFile function chokes on buffers bigger than 64K @@ -27,13 +29,13 @@ details. */ on a remote share, at least on Windows 7 and later. In theory the buffer should have a size of =20 - sizeof (FILE_FULL_EA_INFORMATION) + MAX_EA_NAME_LEN - + MAX_EA_VALUE_LEN + sizeof (FILE_FULL_EA_INFORMATION) + _XATTR_NAME_MAX_ONDISK_ + + XATTR_SIZE_MAX =20 (65804 bytes), but we're opting for simplicity here, and a 64K buffer has the advantage that we can use a tmp_pathbuf buffer, rather than having to alloca 64K from stack. */ -#define EA_BUFSIZ MAX_EA_VALUE_LEN +#define EA_BUFSIZ XATTR_SIZE_MAX =20 #define NEXT_FEA(p) ((PFILE_FULL_EA_INFORMATION) (p->NextEntryOffset \ ? (char *) p + p->NextEntryOffset : NULL)) @@ -55,7 +57,7 @@ read_ea (HANDLE hdl, path_conv &pc, const char *name, cha= r *value, size_t size) returns the last EA entry of the file infinitely. Even utilizing the optional EaIndex only helps marginally. If you use that, the last EA in the file is returned twice. */ - char lastname[MAX_EA_NAME_LEN]; + char lastname[_XATTR_NAME_MAX_ONDISK_]; =20 __try { @@ -95,7 +97,7 @@ read_ea (HANDLE hdl, path_conv &pc, const char *name, cha= r *value, size_t size) __leave; } =20 - if ((nlen =3D strlen (name)) >=3D MAX_EA_NAME_LEN) + if ((nlen =3D strlen (name)) >=3D _XATTR_NAME_MAX_ONDISK_) { set_errno (EINVAL); __leave; @@ -197,7 +199,7 @@ read_ea (HANDLE hdl, path_conv &pc, const char *name, c= har *value, size_t size) /* For compatibility with Linux, we always prepend "user." to the attribute name, so effectively we only support user attributes from a application point of view. */ - char tmpbuf[MAX_EA_NAME_LEN * 2]; + char tmpbuf[_XATTR_NAME_MAX_ONDISK_ * 2]; char *tp =3D stpcpy (tmpbuf, "user."); stpcpy (tp, fea->EaName); /* NTFS stores all EA names in uppercase unfortunately. To @@ -297,7 +299,7 @@ write_ea (HANDLE hdl, path_conv &pc, const char *name, = const char *value, /* Skip "user." prefix. */ name +=3D 5; =20 - if ((nlen =3D strlen (name)) >=3D MAX_EA_NAME_LEN) + if ((nlen =3D strlen (name)) >=3D _XATTR_NAME_MAX_ONDISK_) { set_errno (EINVAL); __leave;