Author: rfm Date: Mon Oct 24 12:22:43 2016 New Revision: 40171 URL: http://svn.gna.org/viewcvs/gnustep?rev=40171&view=rev Log: Fixes for problems spotted by Wolfgang
Modified: libs/base/trunk/ChangeLog libs/base/trunk/Source/NSData.m libs/base/trunk/Source/NSMessagePortNameServer.m libs/base/trunk/Source/NSTask.m Modified: libs/base/trunk/ChangeLog URL: http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=40171&r1=40170&r2=40171&view=diff ============================================================================== --- libs/base/trunk/ChangeLog (original) +++ libs/base/trunk/ChangeLog Mon Oct 24 12:22:43 2016 @@ -1,3 +1,12 @@ +2016-10-24 Richard Frith-Macdonald <r...@gnu.org> + + * Source/NSData.m: Only atempt to read regular files into NSData, + * Source/NSMessagePortNameServer.m: Ignore lock directories in the + 'names' directory. + * Source/NSTask.m Increase files to close from 256 to 2048 to better + reflect typical modern system limits. + All changes for problems spotted by Wolfgang. + 2016-10-21 Richard Frith-Macdonald <r...@gnu.org> * Headers/Foundation/NSDate.h: Add documentation Modified: libs/base/trunk/Source/NSData.m URL: http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSData.m?rev=40171&r1=40170&r2=40171&view=diff ============================================================================== --- libs/base/trunk/Source/NSData.m (original) +++ libs/base/trunk/Source/NSData.m Mon Oct 24 12:22:43 2016 @@ -229,8 +229,10 @@ } static BOOL -readContentsOfFile(NSString* path, void** buf, off_t* len, NSZone* zone) -{ +readContentsOfFile(NSString *path, void **buf, off_t *len, NSZone *zone) +{ + NSFileManager *mgr = [NSFileManager defaultManager]; + NSDictionary *att; #if defined(_WIN32) const unichar *thePath = 0; #else @@ -239,7 +241,7 @@ FILE *theFile = 0; void *tmp = 0; int c; - off_t fileLength; + off_t fileLength; #if defined(_WIN32) thePath = (const unichar*)[path fileSystemRepresentation]; @@ -252,6 +254,13 @@ return NO; } + att = [mgr fileAttributesAtPath: path traverseLink: YES]; + if ([att fileType] != NSFileTypeRegular) + { + NSWarnFLog(@"Open (%@) attempt failed - not a regular file", path); + return NO; + } + #if defined(_WIN32) theFile = _wfopen(thePath, L"rb"); #else @@ -280,10 +289,14 @@ * file) by calling ftello(). */ fileLength = ftello(theFile); - if (fileLength == (off_t) -1) + if (fileLength == (off_t)-1) { NSWarnFLog(@"Ftell on %@ failed - %@", path, [NSError _last]); goto failure; + } + if (fileLength >= 2147483647) + { + fileLength = 0; } /* Modified: libs/base/trunk/Source/NSMessagePortNameServer.m URL: http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSMessagePortNameServer.m?rev=40171&r1=40170&r2=40171&view=diff ============================================================================== --- libs/base/trunk/Source/NSMessagePortNameServer.m (original) +++ libs/base/trunk/Source/NSMessagePortNameServer.m Mon Oct 24 12:22:43 2016 @@ -161,7 +161,13 @@ NSArray *lines; NSString *line; int opid; - + BOOL isDir = NO; + + if ([mgr fileExistsAtPath: old isDirectory: &isDir] == NO + || YES == isDir) + { + continue; // Ignore removed file or lock directory + } lines = [[NSString stringWithContentsOfFile: old] componentsSeparatedByString: @"\n"]; if ([lines count] > 1 Modified: libs/base/trunk/Source/NSTask.m URL: http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSTask.m?rev=40171&r1=40170&r2=40171&view=diff ============================================================================== --- libs/base/trunk/Source/NSTask.m (original) +++ libs/base/trunk/Source/NSTask.m Mon Oct 24 12:22:43 2016 @@ -93,15 +93,11 @@ #include <sys/stropts.h> #endif -#ifndef MAX_OPEN -#define MAX_OPEN 64 -#endif - /* - * If we don't have NFILE, default to 256 open descriptors. + * If we don't have NOFILE, default to 2048 open descriptors. */ #ifndef NOFILE -#define NOFILE 256 +#define NOFILE 2048 #endif _______________________________________________ Gnustep-cvs mailing list Gnustep-cvs@gna.org https://mail.gna.org/listinfo/gnustep-cvs