pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for using a NFSv4 XATTR prefix for Win32 EAs, Win32 EA fixes+misc, 2025-03-20
Posted by Anonymous on Thu 20th Mar 2025 16:37
raw | new post

  1. From 471cc11006af7aa9a56f142906733df2078919c2 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Thu, 20 Mar 2025 11:21:47 +0100
  4. Subject: [PATCH 1/5] tests: Setup instructions for Illumos NFS server should
  5.  default to NFSv4.2
  6.  
  7. Illumos NFS server supports NFSv4.2, so setup instructions should
  8. default to NFSv4.2
  9.  
  10. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  11. ---
  12. tests/nfs_server_setup.txt | 4 ++--
  13.  1 file changed, 2 insertions(+), 2 deletions(-)
  14.  
  15. diff --git a/tests/nfs_server_setup.txt b/tests/nfs_server_setup.txt
  16. index e8340c9..6d0ffcc 100644
  17. --- a/tests/nfs_server_setup.txt
  18. +++ b/tests/nfs_server_setup.txt
  19. @@ -82,7 +82,7 @@ See https://docs.oracle.com/en/operating-systems/solaris/oracle-solaris/11.4/man
  20.  
  21.  
  22.  #
  23. -# Illumos NFSv4.1 server setup
  24. +# Illumos NFSv4.2 server setup
  25.  # (similar to Solaris 11.4)
  26.  #
  27.  
  28. @@ -97,7 +97,7 @@ svcadm enable network/nfs/mapid
  29.  svcadm enable network/nfs/server
  30.  sharectl set -p nfsmapid_domain=global.loc nfs
  31.  sharectl set -p server_delegation=on nfs
  32. -sharectl set -p server_versmax=4.1 nfs
  33. +sharectl set -p server_versmax=4.2 nfs
  34.  
  35.  # prepare test share
  36.  mkdir /nfsdata
  37. --
  38. 2.45.1
  39.  
  40. From b7b5f96158726c4fa0c393c79b3512de45d922b7 Mon Sep 17 00:00:00 2001
  41. From: Roland Mainz <roland.mainz@nrubsig.org>
  42. Date: Thu, 20 Mar 2025 15:13:17 +0100
  43. Subject: [PATCH 2/5] daemon: Add a NFSv4 XATTR filename prefix for Windows
  44.  Extended Attributes
  45.  
  46. Add a NFSv4 XATTR (extended attributes) filename prefix for Windows
  47. Extended Attributes (EA)
  48.  
  49. We need such a prefix to avoid colliding with other users in the
  50. NFSv4 XATTR namespace - for example SUN Microsystrems (Solaris,
  51. Illumos, ...) uses "SUNWattr_" as prefix, and setting such attributes
  52. can cause data corruption (or in case of "SUNWattr_ro" will fail, because
  53. the attribute file is read-only).
  54.  
  55. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  56. ---
  57. daemon/ea.c | 128 +++++++++++++++++++++++++++++++++++++++++-----------
  58.  1 file changed, 102 insertions(+), 26 deletions(-)
  59.  
  60. diff --git a/daemon/ea.c b/daemon/ea.c
  61. index 00211a9..1a9a24c 100644
  62. --- a/daemon/ea.c
  63. +++ b/daemon/ea.c
  64. @@ -1,5 +1,6 @@
  65.  /* NFSv4.1 client for Windows
  66. - * Copyright (C) 2012 The Regents of the University of Michigan
  67. + * Copyright (C) 2012 The Regents of the University of Michigan
  68. + * Copyright (C) 2024-2025 Roland Mainz <roland.mainz@nrubsig.org>
  69.   *
  70.   * Olga Kornievskaia <aglo@umich.edu>
  71.   * Casey Bodley <cbodley@umich.edu>
  72. @@ -31,6 +32,20 @@
  73.  #include "daemon_debug.h"
  74.  #include "nfs_ea.h"
  75.  
  76. +/*
  77. + * |WIN_NFS4_EA_NAME_PREFIX| - Prefix for Windows EA in NFSv4
  78. + * XATTR (extended attributes) namespace
  79. + *
  80. + * We need such a prefix to avoid colliding with other users
  81. + * in the NFSv4 XATTR namespace - for example SUN Microsystrems
  82. + * (Solaris, Illumos, ...) uses "SUNWattr_" as prefix, and setting
  83. + * such attributes can cause data corruption (or in case of
  84. + * "SUNWattr_ro" will fail, because the attribute file is
  85. + * read-only).
  86. + */
  87. +#define WIN_NFS4_EA_NAME_PREFIX "win32.ea."
  88. +#define WIN_NFS4_EA_NAME_PREFIX_LEN (9)
  89. +
  90.  
  91.  #define EALVL 2 /* dprintf level for extended attribute logging */
  92.  
  93. @@ -49,6 +64,19 @@ static int set_ea_value(
  94.      nfs41_write_verf verf;
  95.      uint32_t bytes_written;
  96.      int status;
  97. +    char prefixed_name[256];
  98. +
  99. +    DPRINTF(EALVL,
  100. +        ("set_ea_value: "
  101. +            "ea->(EaName='%.*s' EaNameLength=%d)\n",
  102. +            (int)ea->EaNameLength,
  103. +            ea->EaName,
  104. +            (int)ea->EaNameLength));
  105. +
  106. +    (void)snprintf(prefixed_name, sizeof(prefixed_name), "%s%.*s",
  107. +        WIN_NFS4_EA_NAME_PREFIX,
  108. +        (int)ea->EaNameLength,
  109. +        ea->EaName);
  110.  
  111.      /* don't allow values larger than NFS4_EASIZE */
  112.      if (ea->EaValueLength > NFS4_EASIZE) {
  113. @@ -61,8 +89,8 @@ static int set_ea_value(
  114.      /* remove the file on empty value */
  115.      if (ea->EaValueLength == 0) {
  116.          nfs41_component name;
  117. -        name.name = ea->EaName;
  118. -        name.len = ea->EaNameLength;
  119. +        name.name = prefixed_name;
  120. +        name.len = (USHORT)strlen(prefixed_name);
  121.          nfs41_remove(session, parent, &name, 0);
  122.          status = NFS4_OK;
  123.          goto out;
  124. @@ -70,8 +98,8 @@ static int set_ea_value(
  125.  
  126.      claim.claim = CLAIM_NULL;
  127.      claim.u.null.filename = &file.name;
  128. -    file.name.name = ea->EaName;
  129. -    file.name.len = ea->EaNameLength;
  130. +    file.name.name = prefixed_name;
  131. +    file.name.len = (USHORT)strlen(prefixed_name);
  132.  
  133.      createattrs.attrmask.count = 2;
  134.      createattrs.attrmask.arr[0] = FATTR4_WORD0_SIZE;
  135. @@ -85,9 +113,8 @@ static int set_ea_value(
  136.          &createattrs, TRUE, &stateid.stateid, &delegation, NULL);
  137.      if (status) {
  138.          eprintf("set_ea_value: "
  139. -            "nfs41_open(ea_name='%.*s') failed with '%s'\n",
  140. -            (int)ea->EaNameLength,
  141. -            ea->EaName,
  142. +            "nfs41_open(ea_name='%s') failed with '%s'\n",
  143. +            prefixed_name,
  144.              nfs_error_string(status));
  145.          goto out;
  146.      }
  147. @@ -98,9 +125,8 @@ static int set_ea_value(
  148.          &verf, NULL);
  149.      if (status) {
  150.          eprintf("set_ea_value: "
  151. -            "nfs41_write(ea_name='%.*s') failed with '%s'\n",
  152. -            (int)ea->EaNameLength,
  153. -            ea->EaName,
  154. +            "nfs41_write(ea_name='%s') failed with '%s'\n",
  155. +            prefixed_name,
  156.              nfs_error_string(status));
  157.          goto out_close;
  158.      }
  159. @@ -343,7 +369,13 @@ static uint32_t calculate_ea_list_length(
  160.  
  161.      while (remaining) {
  162.          entry = (const nfs41_readdir_entry*)position;
  163. -        length += ALIGNED_EASIZE(entry->name_len);
  164. +
  165. +        if ((entry->name_len > WIN_NFS4_EA_NAME_PREFIX_LEN) &&
  166. +            (memcmp(entry->name,
  167. +                WIN_NFS4_EA_NAME_PREFIX, WIN_NFS4_EA_NAME_PREFIX_LEN) == 0)) {
  168. +            length +=
  169. +                ALIGNED_EASIZE(entry->name_len-WIN_NFS4_EA_NAME_PREFIX_LEN);
  170. +        }
  171.  
  172.          if (!entry->next_entry_offset)
  173.              break;
  174. @@ -359,21 +391,52 @@ static void populate_ea_list(
  175.      OUT PFILE_GET_EA_INFORMATION ea_list)
  176.  {
  177.      const nfs41_readdir_entry *entry;
  178. -    PFILE_GET_EA_INFORMATION ea = ea_list, prev = NULL;
  179. +    PFILE_GET_EA_INFORMATION ea = ea_list;
  180. +    PFILE_GET_EA_INFORMATION last_win_ea = NULL;
  181. +    bool is_win_ea;
  182.  
  183.      for (;;) {
  184.          entry = (const nfs41_readdir_entry*)position;
  185. -        StringCchCopyA(ea->EaName, entry->name_len, entry->name);
  186. -        ea->EaNameLength = (UCHAR)entry->name_len - 1;
  187. +
  188. +        if ((entry->name_len > WIN_NFS4_EA_NAME_PREFIX_LEN) &&
  189. +            (memcmp(entry->name,
  190. +                WIN_NFS4_EA_NAME_PREFIX, WIN_NFS4_EA_NAME_PREFIX_LEN) == 0)) {
  191. +            is_win_ea = true;
  192. +        }
  193. +        else {
  194. +            is_win_ea = false;
  195. +        }
  196. +
  197. +        if (is_win_ea) {
  198. +            ea->EaNameLength =
  199. +                (UCHAR)(entry->name_len - WIN_NFS4_EA_NAME_PREFIX_LEN);
  200. +            (void)memcpy(ea->EaName,
  201. +                entry->name+WIN_NFS4_EA_NAME_PREFIX_LEN,
  202. +                ea->EaNameLength);
  203. +
  204. +            DPRINTF(EALVL,
  205. +                ("populate_ea_list: adding ea "
  206. +                    "entry->(name='%.*s' name_len=%d) "
  207. +                    "ea->(EaName='%.*s' EaNameLength=%d)\n",
  208. +                    (int)entry->name_len,
  209. +                    entry->name,
  210. +                    (int)entry->name_len,
  211. +                    (int)ea->EaNameLength,
  212. +                    ea->EaName,
  213. +                    (int)ea->EaNameLength));
  214. +            last_win_ea = ea;
  215. +        }
  216.  
  217.          if (!entry->next_entry_offset) {
  218. -            ea->NextEntryOffset = 0;
  219. +            (last_win_ea?last_win_ea:ea)->NextEntryOffset = 0;
  220.              break;
  221.          }
  222.  
  223. -        prev = ea;
  224. -        ea->NextEntryOffset = ALIGNED_EASIZE(ea->EaNameLength);
  225. -        ea = (PFILE_GET_EA_INFORMATION)NEXT_ENTRY(ea);
  226. +        if (is_win_ea) {
  227. +            ea->NextEntryOffset = ALIGNED_EASIZE(ea->EaNameLength);
  228. +            ea = (PFILE_GET_EA_INFORMATION)NEXT_ENTRY(ea);
  229. +        }
  230. +
  231.          position += entry->next_entry_offset;
  232.      }
  233.  }
  234. @@ -442,14 +505,27 @@ static int get_ea_value(
  235.      uint32_t diff, bytes_read;
  236.      bool_t eof;
  237.      int status;
  238. +    char prefixed_name[256];
  239.  
  240.      if (parent->fh.len == 0) /* no named attribute directory */
  241.          goto out_empty;
  242.  
  243. +    DPRINTF(EALVL,
  244. +        ("get_ea_value: "
  245. +            "ea->(EaName='%.*s' EaNameLength=%d)\n",
  246. +            (int)ea->EaNameLength,
  247. +            ea->EaName,
  248. +            (int)ea->EaNameLength));
  249. +
  250. +    (void)snprintf(prefixed_name, sizeof(prefixed_name), "%s%.*s",
  251. +        WIN_NFS4_EA_NAME_PREFIX,
  252. +        (int)ea->EaNameLength,
  253. +        ea->EaName);
  254. +
  255.      claim.claim = CLAIM_NULL;
  256.      claim.u.null.filename = &file.name;
  257. -    file.name.name = ea->EaName;
  258. -    file.name.len = ea->EaNameLength;
  259. +    file.name.name = prefixed_name;
  260. +    file.name.len = (USHORT)strlen(prefixed_name);
  261.  
  262.      status = nfs41_open(session, parent, &file, owner, &claim,
  263.          OPEN4_SHARE_ACCESS_READ | OPEN4_SHARE_ACCESS_WANT_NO_DELEG,
  264. @@ -457,9 +533,8 @@ static int get_ea_value(
  265.          &stateid.stateid, &delegation, &info);
  266.      if (status) {
  267.          eprintf("get_ea_value: "
  268. -            "nfs41_open(ea_name='%.*s') failed with '%s'\n",
  269. -            (int)ea->EaNameLength,
  270. -            ea->EaName,
  271. +            "nfs41_open(ea_name='%s') failed with '%s'\n",
  272. +            prefixed_name,
  273.              nfs_error_string(status));
  274.          if (status == NFS4ERR_NOENT)
  275.              goto out_empty;
  276. @@ -470,7 +545,8 @@ static int get_ea_value(
  277.          status = NFS4ERR_FBIG;
  278.          eprintf("get_ea_value: "
  279.              "EA value for '%s' longer than maximum %u "
  280. -            "(%llu bytes), returning %s\n", ea->EaName, NFS4_EASIZE,
  281. +            "(%llu bytes), returning '%s'\n",
  282. +            prefixed_name, NFS4_EASIZE,
  283.              info.size, nfs_error_string(status));
  284.          goto out_close;
  285.      }
  286. @@ -627,7 +703,7 @@ static int handle_getexattr(void *daemon_context, nfs41_upcall *upcall)
  287.          }
  288.  
  289.          ea->EaNameLength = query->EaNameLength;
  290. -        StringCchCopyA(ea->EaName, (size_t)ea->EaNameLength + 1, query->EaName);
  291. +        (void)memcpy(ea->EaName, query->EaName, ea->EaNameLength);
  292.          ea->Flags = 0;
  293.  
  294.          /* read the value from file */
  295. --
  296. 2.45.1
  297.  
  298. From 39dd639aba76685976bdf8b42cbb9b1fd445046d Mon Sep 17 00:00:00 2001
  299. From: Roland Mainz <roland.mainz@nrubsig.org>
  300. Date: Thu, 20 Mar 2025 16:23:39 +0100
  301. Subject: [PATCH 3/5] tests: Add tests for Windows EAs+NFSv4 XATTRs
  302.  
  303. Add tests for Windows (Extended Attributes) EAs and NFSv4 XATTRs
  304.  
  305. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  306. ---
  307. tests/manual_testing.txt | 60 +++++++++++++++++++++++++++++++++++++++-
  308.  1 file changed, 59 insertions(+), 1 deletion(-)
  309.  
  310. diff --git a/tests/manual_testing.txt b/tests/manual_testing.txt
  311. index 09ef4a6..4740a5d 100644
  312. --- a/tests/manual_testing.txt
  313. +++ b/tests/manual_testing.txt
  314. @@ -1,5 +1,5 @@
  315.  #
  316. -# ms-nfs41-client manual testing sequence, 2025-02-24
  317. +# ms-nfs41-client manual testing sequence, 2025-03-20
  318.  #
  319.  # Draft version, needs to be turned into automated tests
  320.  # if possible
  321. @@ -19,6 +19,7 @@
  322.  #   make
  323.  #   bmake
  324.  #   netpbm
  325. +#   attr
  326.  #   git
  327.  #   subversion
  328.  #   cygport
  329. @@ -373,6 +374,63 @@ icacls mytestfile1.txt | grep --colour -E 'cygwingrp2.+GR'
  330.  #
  331.  
  332.  
  333. +#
  334. +# Tests for Windows EAs (Extended Attributes)
  335. +# Windows EAs are represented as NFSv4 extended attributes (XATTR)
  336. +# files, with the Windows EaName prefixed with "win32.ea." to
  337. +# avoid namespace collision with other users of NFSv4 XATTR files
  338. +# (e.g. SUN Microsystems/Solaris/Illumos/ZFS etc. use "SUNWattr_"
  339. +# as predix
  340. +#
  341. +
  342. +1. One-liner:
  343. +---- snip ----
  344. +$ ksh93 -c 'set -o xtrace -o errexit ; rm -f x1 ; touch x1 ; attr -q -s "fish5" -V "hello lake world" x1 ; [[ "$(attr -q -l x1)" == *fish5* ]] || echo FAIL ; [[ "$(attr -q -g "fish5" x1)" == "hello lake world" ]] || echo "FAIL" ; attr -q -r "fish5" x1 ; echo "# Test OK"'
  345. +---- snip ----
  346. +
  347. +2. Detailed test:
  348. +---- snip ----
  349. +# create parent file
  350. +$ rm -f myattrfile ; touch myattrfile
  351. +
  352. +# list attributes for new file (should be no EAs)
  353. +$ attr -l myattrfile
  354. +
  355. +# create EA attribute "chicken3"
  356. +$ attr -s "chicken3" -V "hello world" myattrfile
  357. +Attribute "chicken3" set to a 11 byte value for myattrfile:
  358. +hello world
  359. +
  360. +# create EA attribute "fish5"
  361. +$ attr -s "fish5" -V "hello lake world" myattrfile
  362. +Attribute "fish5" set to a 16 byte value for myattrfile:
  363. +hello lake world
  364. +
  365. +# list attributes (should be "fish5" and "chicken3"
  366. +$ attr -l myattrfile
  367. +Attribute "fish5" has a 16 byte value for myattrfile
  368. +Attribute "chicken3" has a 11 byte value for myattrfile
  369. +
  370. +# get value of "chicken3" (should be "hello world")
  371. +$ attr -g chicken3 myattrfile
  372. +Attribute "chicken3" had a 11 byte value for myattrfile:
  373. +hello world
  374. +
  375. +# remove attribute "chicken3", try to get it (should fail)
  376. +$ attr -r chicken3 myattrfile
  377. +$ attr -g chicken3 myattrfile
  378. +attr_get: No data available
  379. +Could not get "chicken3" for myattrfile
  380. +---- snip ----
  381. +
  382. +3. Notes:
  383. +On the NFS server side you can observe XATTR attributes like this:
  384. +- Using runat:
  385. +$ runat "x1" "ls -la"
  386. +- Using bash cd(1) -@:
  387. +$ bash -c 'cd -@ "x1" && ls -la'
  388. +
  389. +
  390.  #
  391.  # ksh93 (ast-ksh)
  392.  #
  393. --
  394. 2.45.1
  395.  
  396. From a555eaf921fe861cb5d8f9d36c06a990bcfbe80c Mon Sep 17 00:00:00 2001
  397. From: Roland Mainz <roland.mainz@nrubsig.org>
  398. Date: Thu, 20 Mar 2025 17:01:55 +0100
  399. Subject: [PATCH 4/5] daemon: Cleanup EA macros
  400.  
  401. Cleanup EA macros and put one copy in "daemon/util.h".
  402.  
  403. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  404. ---
  405. daemon/daemon_debug.c |  4 ----
  406.  daemon/ea.c           | 13 ++++++-------
  407.  daemon/util.h         |  4 ++++
  408.  3 files changed, 10 insertions(+), 11 deletions(-)
  409.  
  410. diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
  411. index 493d221..083fe2f 100644
  412. --- a/daemon/daemon_debug.c
  413. +++ b/daemon/daemon_debug.c
  414. @@ -1464,10 +1464,6 @@ void debug_print_ea(PFILE_FULL_EA_INFORMATION ea)
  415.      if (ea == NULL)
  416.          goto out;
  417.  
  418. -#define EA_NEXT_ENTRY(ea) ((PBYTE)(ea) + (ea)->NextEntryOffset)
  419. -#define EA_VALUE(ea) \
  420. -    ((void *)((unsigned char*)(ea)->EaName + (ea)->EaNameLength + 1))
  421. -
  422.      while (1) {
  423.          const char *ea_name = print_ea->EaName;
  424.          size_t ea_name_len = print_ea->EaNameLength;
  425. diff --git a/daemon/ea.c b/daemon/ea.c
  426. index 1a9a24c..8f829c6 100644
  427. --- a/daemon/ea.c
  428. +++ b/daemon/ea.c
  429. @@ -120,7 +120,7 @@ static int set_ea_value(
  430.      }
  431.  
  432.      status = nfs41_write(session, &file, &stateid,
  433. -        (unsigned char*)ea->EaName + ea->EaNameLength + 1,
  434. +        EA_VALUE(ea),
  435.          ea->EaValueLength, 0, FILE_SYNC4, &bytes_written,
  436.          &verf, NULL);
  437.      if (status) {
  438. @@ -149,7 +149,6 @@ static bool is_nfs_ea(
  439.              (!strncmp(EA_NFSSYMLINKTARGETNAME, ea->EaName, ea->EaNameLength))));
  440.  }
  441.  
  442. -#define NEXT_ENTRY(ea) ((PBYTE)(ea) + (ea)->NextEntryOffset)
  443.  
  444.  int nfs41_ea_set(
  445.      IN nfs41_open_state *state,
  446. @@ -172,7 +171,7 @@ int nfs41_ea_set(
  447.  
  448.          if (ea->NextEntryOffset == 0)
  449.              break;
  450. -        ea = (PFILE_FULL_EA_INFORMATION)NEXT_ENTRY(ea);
  451. +        ea = (PFILE_FULL_EA_INFORMATION)EA_NEXT_ENTRY(ea);
  452.      }
  453.  out:
  454.      return status;
  455. @@ -434,7 +433,7 @@ static void populate_ea_list(
  456.  
  457.          if (is_win_ea) {
  458.              ea->NextEntryOffset = ALIGNED_EASIZE(ea->EaNameLength);
  459. -            ea = (PFILE_GET_EA_INFORMATION)NEXT_ENTRY(ea);
  460. +            ea = (PFILE_GET_EA_INFORMATION)EA_NEXT_ENTRY(ea);
  461.          }
  462.  
  463.          position += entry->next_entry_offset;
  464. @@ -677,7 +676,7 @@ static int handle_getexattr(void *daemon_context, nfs41_upcall *upcall)
  465.                      status = ERROR_NO_MORE_FILES; /* STATUS_NO_MORE_EAS */
  466.                  goto out;
  467.              }
  468. -            query = (PFILE_GET_EA_INFORMATION)NEXT_ENTRY(query);
  469. +            query = (PFILE_GET_EA_INFORMATION)EA_NEXT_ENTRY(query);
  470.          }
  471.      }
  472.  
  473. @@ -735,8 +734,8 @@ static int handle_getexattr(void *daemon_context, nfs41_upcall *upcall)
  474.  
  475.          prev = ea;
  476.          ea->NextEntryOffset = needed;
  477. -        ea = (PFILE_FULL_EA_INFORMATION)NEXT_ENTRY(ea);
  478. -        query = (PFILE_GET_EA_INFORMATION)NEXT_ENTRY(query);
  479. +        ea = (PFILE_FULL_EA_INFORMATION)EA_NEXT_ENTRY(ea);
  480. +        query = (PFILE_GET_EA_INFORMATION)EA_NEXT_ENTRY(query);
  481.      }
  482.  
  483.      ea->NextEntryOffset = 0;
  484. diff --git a/daemon/util.h b/daemon/util.h
  485. index 242dfb9..65a1eee 100644
  486. --- a/daemon/util.h
  487. +++ b/daemon/util.h
  488. @@ -55,6 +55,10 @@ typedef ULONGLONG util_reltimestamp;
  489.  #define PTR2PTRDIFF_T(p) ((ptrdiff_t)((char *)((void *)(p)) - ((char *)0)))
  490.  #define PTRDIFF_T2PTR(d) ((void *)(((char *)0) + (d)))
  491.  
  492. +#define EA_NEXT_ENTRY(ea) ((PBYTE)(ea) + (ea)->NextEntryOffset)
  493. +#define EA_VALUE(ea) \
  494. +    ((void *)((unsigned char *)(ea)->EaName + (ea)->EaNameLength + 1))
  495. +
  496.  char *stpcpy(char *restrict s1, const char *restrict s2);
  497.  
  498.  static __inline
  499. --
  500. 2.45.1
  501.  
  502. From 5d5925b346a4c52a37f2e23507d6ae4fcae1aad8 Mon Sep 17 00:00:00 2001
  503. From: Roland Mainz <roland.mainz@nrubsig.org>
  504. Date: Thu, 20 Mar 2025 17:15:20 +0100
  505. Subject: [PATCH 5/5] daemon: Replace |strncmp()| with |memcmp()| when
  506.  comparing EA names if len is identical
  507.  
  508. Replace |strncmp()| with |memcmp()| when comparing EA names if
  509. the string length is identical.
  510.  
  511. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  512. ---
  513. daemon/ea.c | 8 ++++----
  514.  1 file changed, 4 insertions(+), 4 deletions(-)
  515.  
  516. diff --git a/daemon/ea.c b/daemon/ea.c
  517. index 8f829c6..955ae66 100644
  518. --- a/daemon/ea.c
  519. +++ b/daemon/ea.c
  520. @@ -142,11 +142,11 @@ static bool is_nfs_ea(
  521.      PFILE_FULL_EA_INFORMATION ea)
  522.  {
  523.      return (((ea->EaNameLength == EA_NFSV3ATTRIBUTES_LEN) &&
  524. -            (!strncmp(EA_NFSV3ATTRIBUTES, ea->EaName, ea->EaNameLength)))
  525. +            (!memcmp(EA_NFSV3ATTRIBUTES, ea->EaName, ea->EaNameLength)))
  526.          || ((ea->EaNameLength == EA_NFSACTONLINK_LEN) &&
  527. -            (!strncmp(EA_NFSACTONLINK, ea->EaName, ea->EaNameLength)))
  528. +            (!memcmp(EA_NFSACTONLINK, ea->EaName, ea->EaNameLength)))
  529.          || ((ea->EaNameLength == EA_NFSSYMLINKTARGETNAME_LEN) &&
  530. -            (!strncmp(EA_NFSSYMLINKTARGETNAME, ea->EaName, ea->EaNameLength))));
  531. +            (!memcmp(EA_NFSSYMLINKTARGETNAME, ea->EaName, ea->EaNameLength))));
  532.  }
  533.  
  534.  
  535. @@ -210,7 +210,7 @@ static int handle_setexattr(void *daemon_context, nfs41_upcall *upcall)
  536.          OPEN_DELEGATE_READ, FALSE);
  537.  
  538.      if ((ea->EaNameLength == EA_NFSV3ATTRIBUTES_LEN) &&
  539. -        (!strncmp(EA_NFSV3ATTRIBUTES, ea->EaName, ea->EaNameLength))) {
  540. +        (!memcmp(EA_NFSV3ATTRIBUTES, ea->EaName, ea->EaNameLength))) {
  541.          nfs41_file_info info;
  542.          stateid_arg stateid;
  543.  
  544. --
  545. 2.45.1

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at