#706594 nis: hardcoded UID limit in mknetid

Package:
ypserv
Source:
ypserv
Description:
Server daemon for working with Network Information System (NIS)
Submitter:
Vincent McIntyre
Date:
2021-01-24 15:45:04 UTC
Severity:
normal
Tags:
#706594#5
Date:
2013-05-02 05:26:56 UTC
From:
To:
*** Please type your report below this line ***

Hi,

nis supports 32-bit uids pretty well but I discovered mknetid does not -
it hard-codes a uid limit in the insert_user() function.
This has the effect of ignoring all users with uid above the 16-bit limit,
so the netid table that is created can be missing such users.

A suggested fix is attached. It's quite ugly and probably needs
reworking to make proper use of uid_t as well as some clever indexing
to avoid blowing out the uid_liste[] array to 4Gbytes.
But on a system with sufficient memory, it works.

I expect this to be present in 3.17-32 as well.

kind regards
Vince
--- nis-3.17/ypserv-2.19/mknetid/mknetid.h      2001-04-08 14:25:17.000000000 +0000
+++ mknetid.h   2013-05-02 05:05:43.000000000 +0000
@@ -24,4 +24,6 @@
 extern void print_table(void);
 extern int add_group(const char *key, const char *grp);

+#define MKNETID_MAX_UID 4294967295 /* 2**32 - 1 */
+
 #endif
--- nis-3.17/ypserv-2.19/mknetid/netid_hash.c   2001-04-08 14:25:17.000000000 +0000
+++ netid_hash.c        2013-05-02 05:05:52.000000000 +0000
@@ -81,7 +81,7 @@
 static hash_liste_t* user_liste[TABLESIZE];
 static hash_liste_t* host_liste[TABLESIZE];
 static int first = 1;
-static char uid_liste[65535];
+static char uid_liste[MKNETID_MAX_UID];

 static void
 init_table(void)
@@ -103,7 +103,7 @@

   id = atol(uid);

-  if(id > 65534)
+  if(id > (MKNETID_MAX_UID - 1))
     return -2;

   if(uid_liste[id] == 1)