Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 67132b3

Browse files
committed
Some of these were overwriting their argument with a pascal
string. Use own Pstring() routine (which uses a static buffer) everywhere.
1 parent 5f65309 commit 67132b3

4 files changed

Lines changed: 4 additions & 12 deletions

File tree

Mac/Compat/chdir.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ chdir(path)
1111
char *path;
1212
{
1313
WDPBRec pb;
14-
char name[MAXPATH];
1514

16-
strncpy(name, path, sizeof name);
17-
name[MAXPATH-1]= EOS;
18-
pb.ioNamePtr= (StringPtr) c2pstr(name);
15+
pb.ioNamePtr= (StringPtr) Pstring(path);
1916
pb.ioVRefNum= 0;
2017
pb.ioWDDirID= 0;
2118
if (PBHSetVol(&pb, FALSE) != noErr) {

Mac/Compat/macstat.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ macstat(path, buf)
2121
FileParam f;
2222
HFileInfo hf;
2323
} pb;
24-
char name[256];
2524
short err;
2625

27-
pb.d.ioNamePtr = (unsigned char *)c2pstr(strcpy(name, path));
26+
pb.d.ioNamePtr = (unsigned char *)Pstring(path);
2827
pb.d.ioVRefNum = 0;
2928
pb.d.ioFDirIndex = 0;
3029
pb.d.ioDrDirID = 0;

Mac/Compat/mkdir.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ mkdir(path, mode)
1212
int mode; /* Ignored */
1313
{
1414
HFileParam pb;
15-
char name[MAXPATH];
1615

1716
if (!hfsrunning()) {
1817
errno= ENODEV;
1918
return -1;
2019
}
21-
strncpy(name, path, sizeof name);
22-
pb.ioNamePtr= (StringPtr) c2pstr(name);
20+
pb.ioNamePtr= (StringPtr) Pstring(path);
2321
pb.ioVRefNum= 0;
2422
pb.ioDirID= 0;
2523
if (PBDirCreate((HParmBlkPtr)&pb, FALSE) != noErr) {

Mac/Compat/rmdir.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ rmdir(path)
99
char *path;
1010
{
1111
IOParam pb;
12-
char name[MAXPATH];
1312

14-
strncpy(name, path, sizeof name);
15-
pb.ioNamePtr= (StringPtr) c2pstr(name);
13+
pb.ioNamePtr= (StringPtr) Pstring(path);
1614
pb.ioVRefNum= 0;
1715
if (PBDelete((ParmBlkPtr)&pb, FALSE) != noErr) {
1816
errno= EACCES;

0 commit comments

Comments
 (0)