From: Bernhard R. L. <br...@de...> - 2012-06-25 12:06:35
|
I've pushed the following patch: From: "Bernhard R. Link" <br...@de...> Date: Fri, 22 Jun 2012 17:29:25 +0200 Subject: [PATCH] get rid of MAXPATHLEN usage avoid usung file length limits supporting systems without such limits. --- ChangeLog | 1 + src/auth/ssl_auth.c | 2 +- src/common/linelist.c | 8 ++++++-- src/common/user_auth.c | 15 ++++++++++++--- src/include/portable.h | 6 ------ 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2925e6..09c3d62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +2012-06-22 brl get rid of MAXPATHLEN usage 2011-10-26 brl drop --with-ssl, use autoconf macros to look for libssl 2011-10-26 brl set PPD in print filters' environment, if printcap has ppd= set 2011-10-26 brl fix typo breaking kerberos plugin built (except on x86_32) diff --git a/src/auth/ssl_auth.c b/src/auth/ssl_auth.c index 2297cf0..ce3b439 100644 --- a/src/auth/ssl_auth.c +++ b/src/auth/ssl_auth.c @@ -192,7 +192,7 @@ static int SSL_Initialize_ctx( SSL_METHOD *meth = 0; SSL_CTX *ctx = 0; char header[SMALLBUFFER]; - char cabuf[MAXPATHLEN], certbuf[MAXPATHLEN], pwbuf[MAXPATHLEN]; + char certbuf[4096], pwbuf[4096]; struct stat statb; int pid; char *file, *s; diff --git a/src/common/linelist.c b/src/common/linelist.c index 1cd87bc..a35f829 100644 --- a/src/common/linelist.c +++ b/src/common/linelist.c @@ -2375,9 +2375,12 @@ int Make_temp_fd_in_dir( char **temppath, char *dir ) { int tempfd; struct stat statb; - char pathname[MAXPATHLEN]; + int len; + char *pathname; - plp_snprintf(pathname,sizeof(pathname), "%s/temp%02dXXXXXX",dir,Tempfiles.count ); + len = 1 + plp_snprintf(NULL, 0, "%s/temp%02dXXXXXX",dir,Tempfiles.count ); + pathname = malloc_or_die(len, __FILE__, __LINE__); + plp_snprintf(pathname, len, "%s/temp%02dXXXXXX",dir,Tempfiles.count ); tempfd = mkstemp( pathname ); if( tempfd == -1 ){ Errorcode = JFAIL; @@ -2397,6 +2400,7 @@ int Make_temp_fd_in_dir( char **temppath, char *dir ) logerr_die(LOG_INFO, "Make_temp_fd_in_dir: stat '%s' failed ", pathname ); } DEBUG1("Make_temp_fd_in_dir: fd %d, name '%s'", tempfd, pathname ); + free(pathname); return( tempfd ); } diff --git a/src/common/user_auth.c b/src/common/user_auth.c index 3e07bd0..b659373 100644 --- a/src/common/user_auth.c +++ b/src/common/user_auth.c @@ -195,11 +195,18 @@ static void LoadSecurityPlugin(const char *name) { i = lstat(filename, &s); if( i == 0 && S_ISLNK(s.st_mode) ) { + size_t reserved = 4096; ssize_t linklen; - char linkname[MAXPATHLEN]; + char *linkname = malloc_or_die(reserved, + __FILE__, __LINE__); - linklen = readlink(filename, linkname, sizeof(linkname)); - if( linklen > 0 || linklen <sizeof(linkname) ) { + linklen = readlink(filename, linkname, reserved); + while( linklen >= reserved ) { + reserved = linklen + 1; + linkname = realloc_or_die(linkname, reserved, + __FILE__, __LINE__); + } + if( linklen > 0 && linklen < reserved ) { char *realname, *ee; linkname[linklen] = '\0'; @@ -214,10 +221,12 @@ static void LoadSecurityPlugin(const char *name) { *ee = '\0'; if( loadplugin(filename, realname) ) { free(filename); + free(linkname); return; } } + free(linkname); } else if( i == 0 && S_ISREG(s.st_mode) ) { if( loadplugin(filename, name) ) { free(filename); diff --git a/src/include/portable.h b/src/include/portable.h index 83e62a7..d68d311 100644 --- a/src/include/portable.h +++ b/src/include/portable.h @@ -98,12 +98,7 @@ LPRng requires ANSI Standard C compiler /************************************************************************* * SCO OpenServer 5.0.5 *************************************************************************/ -/* normal include files do not define MAXPATHLEN - rather PATHSIZE in - sys/param.h */ #ifdef sco -#ifndef MAXPATHLEN -#define MAXPATHLEN PATHSIZE -#endif /* SCO doesn't define the S_ISSOCK POSIX macro to use in testing the stat.st_mode structure member - it appears as though a socket has st_mode = 0020000 (same as character special) */ @@ -118,7 +113,6 @@ LPRng requires ANSI Standard C compiler *************************************************************************/ #if defined(cray) -#define MAXPATHLEN 1023 #define HAVE_SIGLONGJMP 1 /* configure incorrectly chooses STATVFS */ -- 1.7.10 |