From fa69d08d1358194c9ce6a36e1905371a27301c2f Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Thu, 11 Jun 2009 21:33:00 +0000 Subject: [PATCH] * libmisc/xgetXXbyYY.c, libmisc/xgetpwnam.c, libmisc/xgetgrnam.c, libmisc/xgetpwuid.c, libmisc/xgetgrgid.c, libmisc/xgetspnam.c: Do not limit the size of the buffer to hold the group or user structure. It used to be limited to 16k, which caused issues with groups having many users. --- ChangeLog | 10 +++++++++- NEWS | 3 +++ libmisc/xgetXXbyYY.c | 12 +++++++++--- libmisc/xgetgrgid.c | 3 +-- libmisc/xgetgrnam.c | 3 +-- libmisc/xgetpwnam.c | 3 +-- libmisc/xgetpwuid.c | 3 +-- libmisc/xgetspnam.c | 3 +-- 8 files changed, 26 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 615ea537..752ea133 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,12 @@ -2009-06-06 Nicolas François +2009-06-11 Nicolas François + + * libmisc/xgetXXbyYY.c, libmisc/xgetpwnam.c, libmisc/xgetgrnam.c, + libmisc/xgetpwuid.c, libmisc/xgetgrgid.c, libmisc/xgetspnam.c: Do + not limit the size of the buffer to hold the group or user + structure. It used to be limited to 16k, which caused issues with + groups having many users. + +2009-06-11 Nicolas François * src/su.c, man/su.1.xml: The default behavior (without -p or --login) is to copy most of the environment variables. Revert a diff --git a/NEWS b/NEWS index 8b96b351..fc5dc73c 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ $Id$ shadow-4.1.4.1 -> shadow-4.1.4.2 UNRELEASED +- general + * Improved support for large groups (impacts most tools). + - su * Preserve the DISPLAY and XAUTHORITY environment variables. This was only the case in the non PAM enabled versions. diff --git a/libmisc/xgetXXbyYY.c b/libmisc/xgetXXbyYY.c index 6419aa90..b3d2cd1a 100644 --- a/libmisc/xgetXXbyYY.c +++ b/libmisc/xgetXXbyYY.c @@ -79,7 +79,7 @@ exit (13); } - do { + while (true) { int status; LOOKUP_TYPE *resbuf = NULL; buffer = (char *)realloc (buffer, length); @@ -106,8 +106,14 @@ return NULL; } - length *= 4; - } while (length < MAX_LENGTH); + if (length <= ((size_t)-1 / 4)) { + length *= 4; + } else if (length == (size_t) -1) { + break; + } else { + length = (size_t) -1; + } + } free(buffer); free(result); diff --git a/libmisc/xgetgrgid.c b/libmisc/xgetgrgid.c index f6919740..2ef171d1 100644 --- a/libmisc/xgetgrgid.c +++ b/libmisc/xgetgrgid.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 , Nicolas François + * Copyright (c) 2007 - 2009, Nicolas François * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,7 +58,6 @@ #define ARG_TYPE gid_t #define ARG_NAME gid #define DUP_FUNCTION __gr_dup -#define MAX_LENGTH 0x8000 #define HAVE_FUNCTION_R (defined HAVE_GETGRGID_R) #include "xgetXXbyYY.c" diff --git a/libmisc/xgetgrnam.c b/libmisc/xgetgrnam.c index 3f160414..a07d0c33 100644 --- a/libmisc/xgetgrnam.c +++ b/libmisc/xgetgrnam.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 , Nicolas François + * Copyright (c) 2007 - 2009, Nicolas François * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,7 +58,6 @@ #define ARG_TYPE const char * #define ARG_NAME name #define DUP_FUNCTION __gr_dup -#define MAX_LENGTH 0x8000 #define HAVE_FUNCTION_R (defined HAVE_GETGRNAM_R) #include "xgetXXbyYY.c" diff --git a/libmisc/xgetpwnam.c b/libmisc/xgetpwnam.c index 6b59248d..db65abb7 100644 --- a/libmisc/xgetpwnam.c +++ b/libmisc/xgetpwnam.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 - 2008, Nicolas François + * Copyright (c) 2007 - 2009, Nicolas François * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,7 +58,6 @@ #define ARG_TYPE const char * #define ARG_NAME name #define DUP_FUNCTION __pw_dup -#define MAX_LENGTH 0x8000 #define HAVE_FUNCTION_R (defined HAVE_GETPWNAM_R) #include "xgetXXbyYY.c" diff --git a/libmisc/xgetpwuid.c b/libmisc/xgetpwuid.c index f0fb04c9..89241344 100644 --- a/libmisc/xgetpwuid.c +++ b/libmisc/xgetpwuid.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 , Nicolas François + * Copyright (c) 2007 - 2009, Nicolas François * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,7 +58,6 @@ #define ARG_TYPE uid_t #define ARG_NAME uid #define DUP_FUNCTION __pw_dup -#define MAX_LENGTH 0x8000 #define HAVE_FUNCTION_R (defined HAVE_GETPWUID_R) #include "xgetXXbyYY.c" diff --git a/libmisc/xgetspnam.c b/libmisc/xgetspnam.c index 1705139a..287e97f2 100644 --- a/libmisc/xgetspnam.c +++ b/libmisc/xgetspnam.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008 , Nicolas François + * Copyright (c) 2008 - 2009, Nicolas François * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,7 +58,6 @@ #define ARG_TYPE const char * #define ARG_NAME name #define DUP_FUNCTION __spw_dup -#define MAX_LENGTH 0x8000 #define HAVE_FUNCTION_R (defined HAVE_GETSPNAM_R) #include "xgetXXbyYY.c"