pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


WinSG patch for large number of groups
Posted by Anonymous on Tue 23rd Jul 2024 01:33
raw | new post

  1. $ diff -u winsg.c.original winsg.c
  2. --- winsg.c.original    2024-07-23 02:25:12.855982600 +0200
  3. +++ winsg.c     2024-07-23 02:24:06.536385600 +0200
  4. @@ -44,7 +44,7 @@
  5.  #include <Lmcons.h>
  6.  #include <process.h>
  7.  
  8. -#if 0
  9. +#if 1
  10.  #define D(x) x
  11.  #else
  12.  #define D(x)
  13. @@ -80,10 +80,10 @@
  14.   * always fails in Win10 with |ERROR_INSUFFICIENT_BUFFER| if you
  15.   * just pass the |sizeof(TOKEN_*)| value. Instead of calling
  16.   * |GetTokenInformation()| with |NULL| arg to obtain the size to
  17. - * allocate we just provide 2048 bytes of extra space after the
  18. + * allocate we just provide 8192 bytes of extra space after the
  19.   * |TOKEN_*| size, and pray it is enough
  20.   */
  21. -#define GETTOKINFO_EXTRA_BUFFER (2048)
  22. +#define GETTOKINFO_EXTRA_BUFFER (8192)
  23.  
  24.  D(
  25.  static
  26. @@ -163,9 +163,9 @@
  27.      DWORD tokdatalen;
  28.      PTOKEN_GROUPS ptgroups;
  29.      char namebuffer[GNLEN+1];
  30. -    DWORD namesize = GNLEN+1;
  31. +    DWORD namesize;
  32.      char domainbuffer[UNLEN+1];
  33. -    DWORD domainbuffer_size = sizeof(domainbuffer);
  34. +    DWORD domainbuffer_size;
  35.      SID_NAME_USE name_use;
  36.  
  37.      tokdatalen = sizeof(TOKEN_GROUPS)+GETTOKINFO_EXTRA_BUFFER;
  38. @@ -189,6 +189,9 @@
  39.              continue;
  40.          }
  41.  
  42. +       namesize = sizeof(namebuffer);
  43. +       domainbuffer_size = sizeof(domainbuffer);
  44. +
  45.          if (!LookupAccountSidA(NULL, ptgroups->Groups[i].Sid,
  46.              namebuffer, &namesize, domainbuffer, &domainbuffer_size, &name_use)) {
  47.              D((void)fprintf(stderr, "print_groups_in_token: "
  48. @@ -428,7 +431,7 @@
  49.          "# shelltype=%d, cmd_arg_index=%d, "
  50.          "av[cmd_arg_index]='%s', "
  51.          "new group name '%s'\n",
  52. -        (int)st, cmd_arg_index, av[cmd_arg_index], newgrpname));
  53. +        (int)st, cmd_arg_index, cmd_arg_index>=0?av[cmd_arg_index]:NULL, newgrpname));
  54.  
  55.      if (!OpenProcessToken(GetCurrentProcess(),
  56.          TOKEN_QUERY|TOKEN_ADJUST_DEFAULT|TOKEN_DUPLICATE,

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