summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2001-09-11 09:22:19 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2001-09-11 09:22:19 (GMT)
commitcf0319326a751e4f0e45ac1122d85235bb187b8b (patch)
treecd6a282e22fd6bc38cfb8d583cc6061baac0d6a2 /Mac
parent78e0fc74bce026ddf67d029030a90c9b8faffcb5 (diff)
downloadcpython-cf0319326a751e4f0e45ac1122d85235bb187b8b.zip
cpython-cf0319326a751e4f0e45ac1122d85235bb187b8b.tar.gz
cpython-cf0319326a751e4f0e45ac1122d85235bb187b8b.tar.bz2
Implemented PyMac_GetFullPathname for MacPython.
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Python/macglue.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/Mac/Python/macglue.c b/Mac/Python/macglue.c
index 9c01fd7..4e8c9e4 100644
--- a/Mac/Python/macglue.c
+++ b/Mac/Python/macglue.c
@@ -203,7 +203,7 @@ get_folder_parent (FSSpec * fss, FSSpec * parent)
/* Given an FSSpec return a full, colon-separated pathname */
OSErr
-PyMac_GetFullPath (FSSpec *fss, char *buf)
+PyMac_GetFullPathname (FSSpec *fss, char *buf, int length)
{
short err;
FSSpec fss_parent, fss_current;
@@ -212,6 +212,10 @@ PyMac_GetFullPath (FSSpec *fss, char *buf)
fss_current = *fss;
plen = fss_current.name[0];
+ if ( plen+2 > length ) {
+ *buf = 0;
+ return errFSNameTooLong;
+ }
memcpy(buf, &fss_current.name[1], plen);
buf[plen] = 0;
/* Special case for disk names */
@@ -222,19 +226,25 @@ PyMac_GetFullPath (FSSpec *fss, char *buf)
}
while (fss_current.parID > 1) {
/* Get parent folder name */
- if (err = get_folder_parent(&fss_current, &fss_parent))
+ if (err = get_folder_parent(&fss_current, &fss_parent)) {
+ *buf = 0;
return err;
+ }
fss_current = fss_parent;
/* Prepend path component just found to buf */
plen = fss_current.name[0];
if (strlen(buf) + plen + 1 > 1024) {
/* Oops... Not enough space (shouldn't happen) */
*buf = 0;
- return -1;
+ return errFSNameTooLong;
}
memcpy(tmpbuf, &fss_current.name[1], plen);
tmpbuf[plen] = ':';
strcpy(&tmpbuf[plen+1], buf);
+ if ( strlen(tmpbuf) > length ) {
+ *buf = 0;
+ return errFSNameTooLong;
+ }
strcpy(buf, tmpbuf);
}
return 0;