[Python-checkins] CVS: python/dist/src/Mac/Python macglue.c,1.104,1.105
Jack Jansen
jackjansen@users.sourceforge.net
Tue, 11 Sep 2001 02:22:21 -0700
Update of /cvsroot/python/python/dist/src/Mac/Python
In directory usw-pr-cvs1:/tmp/cvs-serv20236/python/Mac/Python
Modified Files:
macglue.c
Log Message:
Implemented PyMac_GetFullPathname for MacPython.
Index: macglue.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Python/macglue.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -C2 -d -r1.104 -r1.105
*** macglue.c 2001/09/01 22:37:54 1.104
--- macglue.c 2001/09/11 09:22:19 1.105
***************
*** 204,208 ****
OSErr
! PyMac_GetFullPath (FSSpec *fss, char *buf)
{
short err;
--- 204,208 ----
OSErr
! PyMac_GetFullPathname (FSSpec *fss, char *buf, int length)
{
short err;
***************
*** 213,216 ****
--- 213,220 ----
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;
***************
*** 223,228 ****
while (fss_current.parID > 1) {
/* Get parent folder name */
! if (err = get_folder_parent(&fss_current, &fss_parent))
return err;
fss_current = fss_parent;
/* Prepend path component just found to buf */
--- 227,234 ----
while (fss_current.parID > 1) {
/* Get parent folder name */
! if (err = get_folder_parent(&fss_current, &fss_parent)) {
! *buf = 0;
return err;
+ }
fss_current = fss_parent;
/* Prepend path component just found to buf */
***************
*** 231,239 ****
/* Oops... Not enough space (shouldn't happen) */
*buf = 0;
! return -1;
}
memcpy(tmpbuf, &fss_current.name[1], plen);
tmpbuf[plen] = ':';
strcpy(&tmpbuf[plen+1], buf);
strcpy(buf, tmpbuf);
}
--- 237,249 ----
/* Oops... Not enough space (shouldn't happen) */
*buf = 0;
! 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);
}