mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fixes for problems spotted by Wolfgang
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@40171 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3d9ffaf168
commit
1ab80b3f58
4 changed files with 33 additions and 9 deletions
|
@ -1,3 +1,12 @@
|
|||
2016-10-24 Richard Frith-Macdonald <rfm@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 <rfm@gnu.org>
|
||||
|
||||
* Headers/Foundation/NSDate.h: Add documentation
|
||||
|
|
|
@ -229,8 +229,10 @@ encodebase64(unsigned char **dstRef,
|
|||
}
|
||||
|
||||
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 @@ readContentsOfFile(NSString* path, void** buf, off_t* len, NSZone* zone)
|
|||
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 @@ readContentsOfFile(NSString* path, void** buf, off_t* len, NSZone* zone)
|
|||
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,11 +289,15 @@ readContentsOfFile(NSString* path, void** buf, off_t* len, NSZone* zone)
|
|||
* 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;
|
||||
}
|
||||
|
||||
/*
|
||||
* Rewind the file pointer to the beginning, preparing to read in
|
||||
|
|
|
@ -161,7 +161,13 @@ static NSMapTable *portToNamesMap;
|
|||
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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue