pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for ACLs+maximum path component length+misc, 2025-07-30
Posted by Anonymous on Wed 30th Jul 2025 19:08
raw | new post

  1. From a450dbbed037fc6fbe1781c773b40ae0cb276c2f Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Wed, 30 Jul 2025 17:23:01 +0200
  4. Subject: [PATCH 1/3] daemon: ACL code should stop doing |strlen()| on const
  5.  string literals
  6.  
  7. ACL code should stop doing |strlen()| on const string literals,
  8. this eats unneccesary CPU time.
  9.  
  10. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  11. ---
  12. daemon/acl.c         | 116 ++++++++++++++++++++++++++++++-------------
  13.  daemon/nfs41_const.h |  22 ++++++++
  14.  2 files changed, 104 insertions(+), 34 deletions(-)
  15.  
  16. diff --git a/daemon/acl.c b/daemon/acl.c
  17. index 767233b..99e1add 100644
  18. --- a/daemon/acl.c
  19. +++ b/daemon/acl.c
  20. @@ -91,30 +91,38 @@ static void free_sids(PSID *sids, int count)
  21.      free(sids);
  22.  }
  23.  
  24. -static int check_4_special_identifiers(char *who, PSID *sid, DWORD *sid_len,
  25. -                                       BOOLEAN *flag)
  26. +static int check_4_special_identifiers(const char *restrict who,
  27. +    PSID *sid,
  28. +    DWORD *sid_len,
  29. +    BOOLEAN *flag)
  30.  {
  31.      int status = ERROR_SUCCESS;
  32.      WELL_KNOWN_SID_TYPE type = 0;
  33.      *flag = TRUE;
  34. -    if (!strncmp(who, ACE4_OWNER, strlen(ACE4_OWNER)-1))
  35. +
  36. +    /*
  37. +     * Compare |who| against known constant strings, excluding the '@'
  38. +     * symbol. Note that |ACE4_NOBODY| and |ACE4_WIN_NULL_SID| do not
  39. +     * have a '@
  40. +     */
  41. +    if (!strncmp(who, ACE4_OWNER, ACE4_OWNER_LEN-1))
  42.          type = WinCreatorOwnerSid;
  43.  #ifdef NFS41_DRIVER_WS2022_HACKS
  44. -    else if (!strncmp(who, "CREATOR OWNER@", strlen("CREATOR OWNER@")-1))
  45. +    else if (!strncmp(who, ACE4_WIN_CREATOR_OWNER, ACE4_WIN_CREATOR_OWNER_LEN-1))
  46.          type = WinCreatorOwnerSid;
  47.  #endif /* NFS41_DRIVER_WS2022_HACKS */
  48. -    else if (!strncmp(who, ACE4_GROUP, strlen(ACE4_GROUP)-1))
  49. +    else if (!strncmp(who, ACE4_GROUP, ACE4_GROUP_LEN-1))
  50.          type = WinCreatorGroupSid;
  51. -    else if (!strncmp(who, ACE4_EVERYONE, strlen(ACE4_EVERYONE)-1))
  52. +    else if (!strncmp(who, ACE4_EVERYONE, ACE4_EVERYONE_LEN-1))
  53.          type = WinWorldSid;
  54.  #ifdef NFS41_DRIVER_WS2022_HACKS
  55. -    else if (!strncmp(who, "Everyone@", strlen("Everyone@")-1))
  56. +    else if (!strncmp(who, ACE4_WIN_EVERYONE, ACE4_WIN_EVERYONE_LEN-1))
  57.          type = WinWorldSid;
  58.  #endif /* NFS41_DRIVER_WS2022_HACKS */
  59. -    else if (!strncmp(who, ACE4_NOBODY, strlen(ACE4_NOBODY)))
  60. +    else if (!strncmp(who, ACE4_NOBODY, ACE4_NOBODY_LEN))
  61.          type = WinNullSid;
  62.  #ifdef NFS41_DRIVER_WS2022_HACKS
  63. -    else if (!strncmp(who, "NULL SID", strlen("NULL SID")))
  64. +    else if (!strncmp(who, ACE4_WIN_NULL_SID, ACE4_WIN_NULL_SID_LEN))
  65.          type = WinNullSid;
  66.  #endif /* NFS41_DRIVER_WS2022_HACKS */
  67.      else
  68. @@ -523,55 +531,95 @@ out:
  69.  
  70.  static int is_well_known_sid(PSID sid, char *who, SID_NAME_USE *snu_out)
  71.  {
  72. -    int status, i;
  73. -    for (i = 0; i < 78; i++) {
  74. -        status = IsWellKnownSid(sid, (WELL_KNOWN_SID_TYPE)i);
  75. -        if (!status) continue;
  76. -        else {
  77. -            DPRINTF(ACLLVL3, ("WELL_KNOWN_SID_TYPE %d\n", i));
  78. -            switch((WELL_KNOWN_SID_TYPE)i) {
  79. +    const WELL_KNOWN_SID_TYPE test_types[] = {
  80. +        WinCreatorOwnerSid,
  81. +        WinCreatorGroupSid,
  82. +        WinBuiltinUsersSid,
  83. +        WinNullSid,
  84. +        WinAnonymousSid,
  85. +        WinWorldSid,
  86. +        WinAuthenticatedUserSid,
  87. +        WinDialupSid,
  88. +        WinNetworkSid,
  89. +        WinBatchSid,
  90. +        WinInteractiveSid,
  91. +        WinNetworkServiceSid,
  92. +        WinLocalServiceSid,
  93. +        WinServiceSid
  94. +    };
  95. +    const size_t test_types_count = ARRAYSIZE(test_types);
  96. +
  97. +    BOOL ismatch;
  98. +    size_t i;
  99. +
  100. +#ifdef _DEBUG
  101. +    static bool once = true;
  102. +
  103. +    if (once) {
  104. +        once = false;
  105. +        EASSERT(test_types_count == 14);
  106. +        /* Safeguards if someone tampers with the #defines for this */
  107. +        EASSERT(strlen(ACE4_OWNER) == ACE4_OWNER_LEN);
  108. +        EASSERT(strlen(ACE4_GROUP) == ACE4_GROUP_LEN);
  109. +        EASSERT(strlen(ACE4_NOBODY) == ACE4_NOBODY_LEN);
  110. +        EASSERT(strlen(ACE4_ANONYMOUS) == ACE4_ANONYMOUS_LEN);
  111. +        EASSERT(strlen(ACE4_EVERYONE) == ACE4_EVERYONE_LEN);
  112. +    }
  113. +#endif /* _DEBUG */
  114. +
  115. +    for (i = 0; i < test_types_count ; i++) {
  116. +        WELL_KNOWN_SID_TYPE tt = test_types[i];
  117. +
  118. +        ismatch = IsWellKnownSid(sid, tt);
  119. +        if (!ismatch) {
  120. +            continue;
  121. +        }
  122. +
  123. +        DPRINTF(ACLLVL3, ("WELL_KNOWN_SID_TYPE=%d\n", (int)tt));
  124. +        switch(tt) {
  125.              case WinCreatorOwnerSid:
  126. -                memcpy(who, ACE4_OWNER, strlen(ACE4_OWNER)+1);
  127. +                (void)memcpy(who, ACE4_OWNER, ACE4_OWNER_LEN+1);
  128.                  *snu_out = SidTypeUser;
  129.                  return TRUE;
  130.              case WinCreatorGroupSid:
  131.              case WinBuiltinUsersSid:
  132. -                memcpy(who, ACE4_GROUP, strlen(ACE4_GROUP)+1);
  133. +                (void)memcpy(who, ACE4_GROUP, ACE4_GROUP_LEN+1);
  134.                  *snu_out = SidTypeGroup;
  135.                  return TRUE;
  136.              case WinNullSid:
  137. -                memcpy(who, ACE4_NOBODY, strlen(ACE4_NOBODY)+1);
  138. +                (void)memcpy(who, ACE4_NOBODY, ACE4_NOBODY_LEN+1);
  139.                  *snu_out = SidTypeUser;
  140.                  return TRUE;
  141.              case WinAnonymousSid:
  142. -                memcpy(who, ACE4_ANONYMOUS, strlen(ACE4_ANONYMOUS)+1);
  143. +                (void)memcpy(who, ACE4_ANONYMOUS, ACE4_ANONYMOUS_LEN+1);
  144.                  return TRUE;
  145.              case WinWorldSid:
  146. -                memcpy(who, ACE4_EVERYONE, strlen(ACE4_EVERYONE)+1);
  147. +                (void)memcpy(who, ACE4_EVERYONE, ACE4_EVERYONE_LEN+1);
  148.                  *snu_out = SidTypeGroup;
  149.                  return TRUE;
  150.              case WinAuthenticatedUserSid:
  151. -                memcpy(who, ACE4_AUTHENTICATED, strlen(ACE4_AUTHENTICATED)+1);
  152. +                (void)memcpy(who, ACE4_AUTHENTICATED, ACE4_AUTHENTICATED_LEN+1);
  153.                  return TRUE;
  154.              case WinDialupSid:
  155. -                memcpy(who, ACE4_DIALUP, strlen(ACE4_DIALUP)+1);
  156. +                (void)memcpy(who, ACE4_DIALUP, ACE4_DIALUP_LEN+1);
  157.                  return TRUE;
  158.              case WinNetworkSid:
  159. -                memcpy(who, ACE4_NETWORK, strlen(ACE4_NETWORK)+1);
  160. +                (void)memcpy(who, ACE4_NETWORK, ACE4_NETWORK_LEN+1);
  161.                  return TRUE;
  162.              case WinBatchSid:
  163. -                memcpy(who, ACE4_BATCH, strlen(ACE4_BATCH)+1);
  164. +                (void)memcpy(who, ACE4_BATCH, ACE4_BATCH_LEN+1);
  165.                  return TRUE;
  166.              case WinInteractiveSid:
  167. -                memcpy(who, ACE4_INTERACTIVE, strlen(ACE4_INTERACTIVE)+1);
  168. +                (void)memcpy(who, ACE4_INTERACTIVE, ACE4_INTERACTIVE_LEN+1);
  169.                  return TRUE;
  170.              case WinNetworkServiceSid:
  171.              case WinLocalServiceSid:
  172.              case WinServiceSid:
  173. -                memcpy(who, ACE4_SERVICE, strlen(ACE4_SERVICE)+1);
  174. +                (void)memcpy(who, ACE4_SERVICE, ACE4_SERVICE_LEN+1);
  175.                  return TRUE;
  176. -            default: return FALSE;
  177. -            }
  178. +            default:
  179. +                eprintf("is_well_known_sid: unknown tt=%d\n", (int)tt);
  180. +                return FALSE;
  181.          }
  182.      }
  183.      return FALSE;
  184. @@ -939,7 +987,7 @@ int map_sid2nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid,
  185.      if (owner_sid) {
  186.          if (EqualSid(sid, owner_sid)) {
  187.              DPRINTF(ACLLVL2, ("this is owner's sid\n"));
  188. -            memcpy(who_out, ACE4_OWNER, strlen(ACE4_OWNER)+1);
  189. +            (void)memcpy(who_out, ACE4_OWNER, ACE4_OWNER_LEN+1);
  190.              sid_type = SidTypeUser;
  191.              status = ERROR_SUCCESS;
  192.              goto out;
  193. @@ -948,7 +996,7 @@ int map_sid2nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid,
  194.      if (group_sid) {
  195.          if (EqualSid(sid, group_sid)) {
  196.              DPRINTF(ACLLVL2, ("this is group's sid\n"));
  197. -            memcpy(who_out, ACE4_GROUP, strlen(ACE4_GROUP)+1);
  198. +            memcpy(who_out, ACE4_GROUP, ACE4_GROUP_LEN+1);
  199.              sid_type = SidTypeGroup;
  200.              status = ERROR_SUCCESS;
  201.              goto out;
  202. @@ -956,8 +1004,8 @@ int map_sid2nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid,
  203.      }
  204.      status = is_well_known_sid(sid, who_out, &sid_type);
  205.      if (status) {
  206. -        if (!strncmp(who_out, ACE4_NOBODY, strlen(ACE4_NOBODY))) {
  207. -            who_size = (DWORD)strlen(ACE4_NOBODY);
  208. +        if (!strncmp(who_out, ACE4_NOBODY, ACE4_NOBODY_LEN)) {
  209. +            who_size = (DWORD)ACE4_NOBODY_LEN;
  210.              goto add_domain;
  211.          }
  212.  
  213. @@ -1160,7 +1208,7 @@ static int map_dacl_2_nfs4acl(PACL acl, PSID sid, PSID gsid, nfsacl41 *nfs4_acl,
  214.              goto out;
  215.          }
  216.          nfs4_acl->flag = 0;
  217. -        memcpy(nfs4_acl->aces->who, ACE4_EVERYONE, strlen(ACE4_EVERYONE)+1);
  218. +        (void)memcpy(nfs4_acl->aces->who, ACE4_EVERYONE, ACE4_EVERYONE_LEN+1);
  219.          nfs4_acl->aces->acetype = ACE4_ACCESS_ALLOWED_ACE_TYPE;
  220.  
  221.          if (file_type == NF4DIR) {
  222. diff --git a/daemon/nfs41_const.h b/daemon/nfs41_const.h
  223. index 84b49b1..efb573a 100644
  224. --- a/daemon/nfs41_const.h
  225. +++ b/daemon/nfs41_const.h
  226. @@ -468,16 +468,38 @@ enum nfs_ftype4 {
  227.  
  228.  /* ACLS well-defined WHOs */
  229.  #define ACE4_OWNER "OWNER@"
  230. +#define ACE4_OWNER_LEN (sizeof(ACE4_OWNER)-1)
  231.  #define ACE4_GROUP "GROUP@"
  232. +#define ACE4_GROUP_LEN (sizeof(ACE4_GROUP)-1)
  233.  #define ACE4_EVERYONE "EVERYONE@"
  234. +#define ACE4_EVERYONE_LEN (sizeof(ACE4_EVERYONE)-1)
  235.  #define ACE4_INTERACTIVE "INTERACTIVE@"
  236. +#define ACE4_INTERACTIVE_LEN (sizeof(ACE4_INTERACTIVE)-1)
  237.  #define ACE4_NETWORK "NETWORK@"
  238. +#define ACE4_NETWORK_LEN (sizeof(ACE4_NETWORK)-1)
  239.  #define ACE4_DIALUP "DIALUP@"
  240. +#define ACE4_DIALUP_LEN (sizeof(ACE4_DIALUP)-1)
  241.  #define ACE4_BATCH "BATCH@"
  242. +#define ACE4_BATCH_LEN (sizeof(ACE4_BATCH)-1)
  243.  #define ACE4_ANONYMOUS "ANONYMOUS@"
  244. +#define ACE4_ANONYMOUS_LEN (sizeof(ACE4_ANONYMOUS)-1)
  245.  #define ACE4_AUTHENTICATED "AUTHENTICATED@"
  246. +#define ACE4_AUTHENTICATED_LEN (sizeof(ACE4_AUTHENTICATED)-1)
  247.  #define ACE4_SERVICE "SERVICE@"
  248. +#define ACE4_SERVICE_LEN (sizeof(ACE4_SERVICE)-1)
  249.  #define ACE4_NOBODY "nobody"
  250. +#define ACE4_NOBODY_LEN (sizeof(ACE4_NOBODY)-1)
  251. +
  252. +#ifdef NFS41_DRIVER_WS2022_HACKS
  253. +/* Names used by Microsoft Windows 2019/2022 NFSv4.1 server */
  254. +#define ACE4_WIN_CREATOR_OWNER "CREATOR OWNER@"
  255. +#define ACE4_WIN_CREATOR_OWNER_LEN (sizeof(ACE4_WIN_CREATOR_OWNER)-1)
  256. +#define ACE4_WIN_EVERYONE "Everyone@"
  257. +#define ACE4_WIN_EVERYONE_LEN (sizeof(ACE4_WIN_EVERYONE)-1)
  258. +#define ACE4_WIN_NULL_SID "NULL_SID"
  259. +#define ACE4_WIN_NULL_SID_LEN (sizeof(ACE4_WIN_NULL_SID)-1)
  260. +#endif /* NFS41_DRIVER_WS2022_HACKS */
  261. +
  262.  
  263.  /* ACLE nfsacl41 aclflag4 constants */
  264.  #define ACL4_AUTO_INHERIT         0x00000001
  265. --
  266. 2.45.1
  267.  
  268. From ca0c172c3a60de5ac4275d179683224d6cced201 Mon Sep 17 00:00:00 2001
  269. From: Roland Mainz <roland.mainz@nrubsig.org>
  270. Date: Wed, 30 Jul 2025 17:58:04 +0200
  271. Subject: [PATCH 2/3] daemon: Add better debug output for ACE failures
  272.  
  273. Add better debug output for ACE failures.
  274.  
  275. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  276. ---
  277. daemon/acl.c | 22 ++++++++++++++--------
  278.  1 file changed, 14 insertions(+), 8 deletions(-)
  279.  
  280. diff --git a/daemon/acl.c b/daemon/acl.c
  281. index 99e1add..56d297a 100644
  282. --- a/daemon/acl.c
  283. +++ b/daemon/acl.c
  284. @@ -272,23 +272,29 @@ static int convert_nfs4acl_2_dacl(nfs41_daemon_globals *nfs41dg,
  285.                      win_aceflags, mask, sids[win_i]);
  286.                  if (!status) {
  287.                      eprintf("convert_nfs4acl_2_dacl: "
  288. -                        "AddAccessAllowedAceEx(dacl=0x%p,win_aceflags=0x%x,mask=0x%x) failed "
  289. -                        "with status=%d\n",
  290. -                        dacl, (int)win_aceflags, (int)mask, status);
  291. +                        "AddAccessAllowedAceEx"
  292. +                        "(dacl=0x%p,win_aceflags=0x%x,mask=0x%x,who='%s') "
  293. +                        "failed with lasterr=%d\n",
  294. +                        dacl, (int)win_aceflags, (int)mask,
  295. +                        curr_nfsace->who, (int)GetLastError());
  296. +                    status = ERROR_INTERNAL_ERROR;
  297.                      goto out_free_dacl;
  298.                  }
  299. -                else status = ERROR_SUCCESS;
  300. +                status = ERROR_SUCCESS;
  301.              } else if (curr_nfsace->acetype == ACE4_ACCESS_DENIED_ACE_TYPE) {
  302.                  status = AddAccessDeniedAceEx(dacl, ACL_REVISION,
  303.                      win_aceflags, mask, sids[win_i]);
  304.                  if (!status) {
  305.                      eprintf("convert_nfs4acl_2_dacl: "
  306. -                        "AddAccessDeniedAceEx(dacl=0x%p,win_aceflags=0x%x,mask=0x%x) failed "
  307. -                        "with status=%d\n",
  308. -                        dacl, (int)win_aceflags, (int)mask, status);
  309. +                        "AddAccessDeniedAceEx"
  310. +                        "(dacl=0x%p,win_aceflags=0x%x,mask=0x%x,who='%s') "
  311. +                        "failed with lasterr=%d\n",
  312. +                        dacl, (int)win_aceflags, (int)mask,
  313. +                        curr_nfsace->who, (int)GetLastError());
  314. +                    status = ERROR_INTERNAL_ERROR;
  315.                      goto out_free_dacl;
  316.                  }
  317. -                else status = ERROR_SUCCESS;
  318. +                status = ERROR_SUCCESS;
  319.              } else {
  320.                  eprintf("convert_nfs4acl_2_dacl: unknown acetype %d\n",
  321.                          curr_nfsace->acetype);
  322. --
  323. 2.45.1
  324.  
  325. From 32e74db9518defa4770408ae569566814c75d80f Mon Sep 17 00:00:00 2001
  326. From: Roland Mainz <roland.mainz@nrubsig.org>
  327. Date: Wed, 30 Jul 2025 18:20:44 +0200
  328. Subject: [PATCH 3/3] daemon: Maximum Win32 path component length should be
  329.  255, not 256
  330.  
  331. Maximum Win32 path component length should be 255 characters, not
  332. 256 characters.
  333.  
  334. Win32 only supports up to 255, anything higher will cause subtle
  335. (because we were only 1 character over the limit) API breakage.
  336.  
  337. Reported-by: Lionel Cons <Lionelcons1972@gmail.com>
  338. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  339. ---
  340. daemon/name_cache.c  | 6 +++---
  341.  daemon/nfs41_const.h | 2 +-
  342.  daemon/readdir.c     | 6 +++---
  343.  daemon/util.c        | 4 ++--
  344.  4 files changed, 9 insertions(+), 9 deletions(-)
  345.  
  346. diff --git a/daemon/name_cache.c b/daemon/name_cache.c
  347. index 950c188..14295cc 100644
  348. --- a/daemon/name_cache.c
  349. +++ b/daemon/name_cache.c
  350. @@ -504,7 +504,7 @@ static void copy_attrs(
  351.  /* name cache */
  352.  RB_HEAD(name_tree, name_cache_entry);
  353.  struct name_cache_entry {
  354. -    char                    component[NFS41_MAX_COMPONENT_LEN];
  355. +    char                    component[NFS41_MAX_COMPONENT_LEN+1];
  356.      nfs41_fh                fh;
  357.      RB_ENTRY(name_cache_entry) rbnode;
  358.      struct name_tree        rbchildren;
  359. @@ -552,7 +552,7 @@ static __inline void name_cache_entry_rename(
  360.      OUT struct name_cache_entry *entry,
  361.      IN const nfs41_component *component)
  362.  {
  363. -    StringCchCopyNA(entry->component, NFS41_MAX_COMPONENT_LEN,
  364. +    StringCchCopyNA(entry->component, NFS41_MAX_COMPONENT_LEN+1,
  365.          component->name, component->len);
  366.      entry->component_len = component->len;
  367.  }
  368. @@ -752,7 +752,7 @@ static struct name_cache_entry* name_cache_search(
  369.      DPRINTF(NCLVL2, ("--> name_cache_search('%.*s' under '%s')\n",
  370.          component->len, component->name, parent->component));
  371.  
  372. -    StringCchCopyNA(tmp.component, NFS41_MAX_COMPONENT_LEN,
  373. +    StringCchCopyNA(tmp.component, NFS41_MAX_COMPONENT_LEN+1,
  374.          component->name, component->len);
  375.      tmp.component_len = component->len;
  376.  
  377. diff --git a/daemon/nfs41_const.h b/daemon/nfs41_const.h
  378. index efb573a..74ad31d 100644
  379. --- a/daemon/nfs41_const.h
  380. +++ b/daemon/nfs41_const.h
  381. @@ -84,7 +84,7 @@
  382.   * NFS41_MAX_COMPONENT_LEN - MaximumComponentNameLength
  383.   * reported for FileFsAttributeInformation
  384.   */
  385. -#define NFS41_MAX_COMPONENT_LEN     256
  386. +#define NFS41_MAX_COMPONENT_LEN     255
  387.  /*
  388.   * NFS41_MAX_PATH_LEN - Maximum path length
  389.   * Notes:
  390. diff --git a/daemon/readdir.c b/daemon/readdir.c
  391. index ae19d43..f809c9d 100644
  392. --- a/daemon/readdir.c
  393. +++ b/daemon/readdir.c
  394. @@ -754,7 +754,7 @@ static int handle_readdir(void *deamon_context, nfs41_upcall *upcall)
  395.      bool_t eof;
  396.      /* make sure we allocate enough space for one nfs41_readdir_entry */
  397.      const uint32_t max_buf_len = max(args->buf_len,
  398. -        sizeof(nfs41_readdir_entry) + NFS41_MAX_COMPONENT_LEN);
  399. +        sizeof(nfs41_readdir_entry) + NFS41_MAX_COMPONENT_LEN+1);
  400.  
  401.      DPRINTF(1, ("--> handle_nfs41_dirquery(filter='%s',initial=%d,restart=%d,single=%d)\n",
  402.          args->filter, (int)args->initial, (int)args->restart, (int)args->single));
  403. @@ -836,9 +836,9 @@ fetch_entries:
  404.          nfs41_readdir_entry *entry = (nfs41_readdir_entry*)entry_buf;
  405.          entry->cookie = 0;
  406.          entry->name_len = (uint32_t)strlen(args->filter) + 1;
  407. -        if (entry->name_len >= NFS41_MAX_COMPONENT_LEN) {
  408. +        if (entry->name_len >= (NFS41_MAX_COMPONENT_LEN+1)) {
  409.              DPRINTF(1,
  410. -                ("entry->name_len(=%d) >= NFS41_MAX_COMPONENT_LEN\n",
  411. +                ("entry->name_len(=%d) >= (NFS41_MAX_COMPONENT_LEN+1)\n",
  412.                  (int)entry->name_len));
  413.              status = ERROR_FILENAME_EXCED_RANGE;
  414.              goto out_free_cookie;
  415. diff --git a/daemon/util.c b/daemon/util.c
  416. index bf99ac1..aac239d 100644
  417. --- a/daemon/util.c
  418. +++ b/daemon/util.c
  419. @@ -350,7 +350,7 @@ int create_silly_rename(
  420.  #define SILLY_RENAME_PREPOSTFIX_LEN (6L)
  421.      const unsigned short extra_len =
  422.          SILLY_RENAME_PREPOSTFIX_LEN + MD5_HASH_LEN;
  423. -    char name[NFS41_MAX_COMPONENT_LEN+1];
  424. +    char name[NFS41_MAX_COMPONENT_LEN];
  425.      unsigned char fhmd5[MD5_HASH_LEN+1];
  426.      char *tmp;
  427.      int status = NO_ERROR, i;
  428. @@ -395,7 +395,7 @@ int create_silly_rename(
  429.      }
  430.  
  431.      last_component(path->path, path->path + path->len, silly);
  432. -    (void)StringCchCopyNA(name, NFS41_MAX_COMPONENT_LEN+1,
  433. +    (void)StringCchCopyNA(name, NFS41_MAX_COMPONENT_LEN,
  434.          silly->name, silly->len);
  435.  
  436.      tmp = (char*)silly->name;
  437. --
  438. 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