Revision: 9797 http://pure-data.svn.sourceforge.net/pure-data/?rev=9797&view=rev Author: eighthave Date: 2008-05-14 10:37:20 -0700 (Wed, 14 May 2008)
Log Message: ----------- patch #1963983
On Windows, FILENAME_MAX is much smaller than MAXPDSTRING, so I replaced MAXPDSTRING with FILENAME_MAX everywhere I could find that is related to filenames. FILENAME_MAX is a POSIX standard macro for defining the max length of a complete filename.
The current situation could result in crashes on Windows.
Added Paths: ----------- trunk/packages/patches/use_FILENAME_MAX_for_file_operations-0.41.4.patch
Added: trunk/packages/patches/use_FILENAME_MAX_for_file_operations-0.41.4.patch =================================================================== --- trunk/packages/patches/use_FILENAME_MAX_for_file_operations-0.41.4.patch (rev 0) +++ trunk/packages/patches/use_FILENAME_MAX_for_file_operations-0.41.4.patch 2008-05-14 17:37:20 UTC (rev 9797) @@ -0,0 +1,645 @@ +Index: m_pd.h +=================================================================== +--- m_pd.h (revision 9725) ++++ m_pd.h (working copy) +@@ -51,7 +51,7 @@ + #include <stddef.h> /* just for size_t -- how lame! */ + #endif + +-#define MAXPDSTRING 1000 /* use this for anything you want */ ++#define MAXPDSTRING 1000 /* must be >= FILENAME_MAX */ + #define MAXPDARG 5 /* max number of args we can typecheck today */ + + /* signed and unsigned integer types the size of a pointer: */ +Index: g_editor.c +=================================================================== +--- g_editor.c (revision 9725) ++++ g_editor.c (working copy) +@@ -979,7 +979,7 @@ + "open," or "help." */ + static void canvas_done_popup(t_canvas *x, t_float which, t_float xpos, t_float ypos) + { +- char pathbuf[MAXPDSTRING], namebuf[MAXPDSTRING]; ++ char pathbuf[FILENAME_MAX], namebuf[FILENAME_MAX]; + t_gobj *y; + for (y = x->gl_list; y; y = y->g_next) + { +@@ -1011,7 +1011,7 @@ + t_atom *av = binbuf_getvec(ob->te_binbuf); + if (ac < 1) + return; +- atom_string(av, namebuf, MAXPDSTRING); ++ atom_string(av, namebuf, FILENAME_MAX); + dir = canvas_getdir((t_canvas *)y)->s_name; + } + else +Index: s_file.c +=================================================================== +--- s_file.c (revision 9725) ++++ s_file.c (working copy) +@@ -43,23 +43,23 @@ + + static void sys_initloadpreferences( void) + { +- char filenamebuf[MAXPDSTRING], *homedir = getenv("HOME"); ++ char filenamebuf[FILENAME_MAX], *homedir = getenv("HOME"); + int fd, length; +- char user_prefs_file[MAXPDSTRING]; /* user prefs file */ ++ char user_prefs_file[FILENAME_MAX]; /* user prefs file */ + /* default prefs embedded in the package */ +- char default_prefs_file[MAXPDSTRING]; ++ char default_prefs_file[FILENAME_MAX]; + struct stat statbuf; + +- snprintf(default_prefs_file, MAXPDSTRING, "%s/default.pdsettings", ++ snprintf(default_prefs_file, FILENAME_MAX, "%s/default.pdsettings", + sys_libdir->s_name); + if (homedir) +- snprintf(user_prefs_file, MAXPDSTRING, "%s/.pdsettings", homedir); ++ snprintf(user_prefs_file, FILENAME_MAX, "%s/.pdsettings", homedir); + if (stat(user_prefs_file, &statbuf) == 0) +- strncpy(filenamebuf, user_prefs_file, MAXPDSTRING); ++ strncpy(filenamebuf, user_prefs_file, FILENAME_MAX); + else if (stat(default_prefs_file, &statbuf) == 0) +- strncpy(filenamebuf, default_prefs_file, MAXPDSTRING); ++ strncpy(filenamebuf, default_prefs_file, FILENAME_MAX); + else return; +- filenamebuf[MAXPDSTRING-1] = 0; ++ filenamebuf[FILENAME_MAX-1] = 0; + if ((fd = open(filenamebuf, 0)) < 0) + { + if (sys_verbose) +@@ -128,17 +128,17 @@ + + static void sys_initsavepreferences( void) + { +- char filenamebuf[MAXPDSTRING], errbuf[MAXPDSTRING], ++ char filenamebuf[FILENAME_MAX], errbuf[FILENAME_MAX], + *homedir = getenv("HOME"); + FILE *fp; + + if (!homedir) + return; +- snprintf(filenamebuf, MAXPDSTRING, "%s/.pdsettings", homedir); +- filenamebuf[MAXPDSTRING-1] = 0; ++ snprintf(filenamebuf, FILENAME_MAX, "%s/.pdsettings", homedir); ++ filenamebuf[FILENAME_MAX-1] = 0; + if ((sys_prefsavefp = fopen(filenamebuf, "w")) == NULL) + { +- snprintf(errbuf, MAXPDSTRING, "%s: %s",filenamebuf, strerror(errno)); ++ snprintf(errbuf, FILENAME_MAX, "%s: %s",filenamebuf, strerror(errno)); + pd_error(0, errbuf); + } + } +@@ -228,15 +228,15 @@ + { + char cmdbuf[256]; + int nread = 0, nleft = size; +- char embedded_prefs[MAXPDSTRING]; +- char user_prefs[MAXPDSTRING]; ++ char embedded_prefs[FILENAME_MAX]; ++ char user_prefs[FILENAME_MAX]; + char *homedir = getenv("HOME"); + struct stat statbuf; + /* the 'defaults' command expects the filename without .plist at the + end */ +- snprintf(embedded_prefs, MAXPDSTRING, "%s/../org.puredata.pd", ++ snprintf(embedded_prefs, FILENAME_MAX, "%s/../org.puredata.pd", + sys_libdir->s_name); +- snprintf(user_prefs, MAXPDSTRING, ++ snprintf(user_prefs, FILENAME_MAX, + "%s/Library/Preferences/org.puredata.pd.plist", homedir); + if (stat(user_prefs, &statbuf) == 0) + snprintf(cmdbuf, 256, "defaults read org.puredata.pd %s 2> /dev/null\n", +Index: configure.in +=================================================================== +--- configure.in (revision 9725) ++++ configure.in (working copy) +@@ -347,11 +347,11 @@ + OSNUMBER=2 + if test x$jack = "xyes"; + then +- LDFLAGS=$LDFLAGS" -weak_framework Jack" ++ LDFLAGS=$LDFLAGS" -weak_framework Jackmp" + fi + if test x$jack = "xrun"; + then +- LDFLAGS=$LDFLAGS" -weak_framework Jack" ++ LDFLAGS=$LDFLAGS" -weak_framework Jackmp" + fi + fi + +Index: s_main.c +=================================================================== +--- s_main.c (revision 9725) ++++ s_main.c (working copy) +@@ -177,9 +177,9 @@ + + static void openit(const char *dirname, const char *filename) + { +- char dirbuf[MAXPDSTRING], *nameptr; ++ char dirbuf[FILENAME_MAX], *nameptr; + int fd = open_via_path(dirname, filename, "", dirbuf, &nameptr, +- MAXPDSTRING, 0); ++ FILENAME_MAX, 0); + if (fd >= 0) + { + close (fd); +@@ -430,7 +430,7 @@ + INSTALL_PREFIX. In MSW, we don't try to use INSTALL_PREFIX. */ + void sys_findprogdir(char *progname) + { +- char sbuf[MAXPDSTRING], sbuf2[MAXPDSTRING], *sp; ++ char sbuf[FILENAME_MAX], sbuf2[FILENAME_MAX], *sp; + char *lastslash; + #ifdef UNISTD + struct stat statbuf; +@@ -439,12 +439,12 @@ + /* find out by what string Pd was invoked; put answer in "sbuf". */ + #ifdef MSW + GetModuleFileName(NULL, sbuf2, sizeof(sbuf2)); +- sbuf2[MAXPDSTRING-1] = 0; ++ sbuf2[FILENAME_MAX-1] = 0; + sys_unbashfilename(sbuf2, sbuf); + #endif /* MSW */ + #ifdef UNISTD +- strncpy(sbuf, progname, MAXPDSTRING); +- sbuf[MAXPDSTRING-1] = 0; ++ strncpy(sbuf, progname, FILENAME_MAX); ++ sbuf[FILENAME_MAX-1] = 0; + #endif + lastslash = strrchr(sbuf, '/'); + if (lastslash) +@@ -491,16 +491,16 @@ + sys_libdir = gensym(sbuf2); + sys_guidir = &s_; /* in MSW the guipath just depends on the libdir */ + #else +- strncpy(sbuf, sbuf2, MAXPDSTRING-30); +- sbuf[MAXPDSTRING-30] = 0; ++ strncpy(sbuf, sbuf2, FILENAME_MAX-30); ++ sbuf[FILENAME_MAX-30] = 0; + strcat(sbuf, "/lib/pd"); + if (stat(sbuf, &statbuf) >= 0) + { + /* complicated layout: lib dir is the one we just stat-ed above */ + sys_libdir = gensym(sbuf); + /* gui lives in .../lib/pd/bin */ +- strncpy(sbuf, sbuf2, MAXPDSTRING-30); +- sbuf[MAXPDSTRING-30] = 0; ++ strncpy(sbuf, sbuf2, FILENAME_MAX-30); ++ sbuf[FILENAME_MAX-30] = 0; + strcat(sbuf, "/lib/pd/bin"); + sys_guidir = gensym(sbuf); + } +@@ -509,8 +509,8 @@ + /* simple layout: lib dir is the parent */ + sys_libdir = gensym(sbuf2); + /* gui lives in .../bin */ +- strncpy(sbuf, sbuf2, MAXPDSTRING-30); +- sbuf[MAXPDSTRING-30] = 0; ++ strncpy(sbuf, sbuf2, FILENAME_MAX-30); ++ sbuf[FILENAME_MAX-30] = 0; + strcat(sbuf, "/bin"); + sys_guidir = gensym(sbuf); + } +@@ -525,7 +525,6 @@ + + int sys_argparse(int argc, char **argv) + { +- char sbuf[MAXPDSTRING]; + int i; + while ((argc > 0) && **argv == '-') + { +@@ -901,7 +900,7 @@ + from command-line arguments */ + static void sys_afterargparse(void) + { +- char sbuf[MAXPDSTRING]; ++ char sbuf[FILENAME_MAX]; + int i; + int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV]; + int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV]; +@@ -909,13 +908,13 @@ + int nmidiindev = 0, midiindev[MAXMIDIINDEV]; + int nmidioutdev = 0, midioutdev[MAXMIDIOUTDEV]; + /* add "extra" library to path */ +- strncpy(sbuf, sys_libdir->s_name, MAXPDSTRING-30); +- sbuf[MAXPDSTRING-30] = 0; ++ strncpy(sbuf, sys_libdir->s_name, FILENAME_MAX-30); ++ sbuf[FILENAME_MAX-30] = 0; + strcat(sbuf, "/extra"); + sys_setextrapath(sbuf); + /* add "doc/5.reference" library to helppath */ +- strncpy(sbuf, sys_libdir->s_name, MAXPDSTRING-30); +- sbuf[MAXPDSTRING-30] = 0; ++ strncpy(sbuf, sys_libdir->s_name, FILENAME_MAX-30); ++ sbuf[FILENAME_MAX-30] = 0; + strcat(sbuf, "/doc/5.reference"); + sys_helppath = namelist_append_files(sys_helppath, sbuf); + /* correct to make audio and MIDI device lists zero based. On +Index: s_path.c +=================================================================== +--- s_path.c (revision 9725) ++++ s_path.c (working copy) +@@ -22,6 +22,10 @@ + #include <io.h> + #endif + ++#ifdef MSW ++#include <windows.h> ++#endif ++ + #include <string.h> + #include "m_pd.h" + #include "m_imp.h" +@@ -69,6 +73,30 @@ + *to = 0; + } + ++/* expand env vars and ~ at the beginning of a path and make a copy to return */ ++static void sys_expandpath(const char *from, char *to) ++{ ++ if ((strlen(from) == 1 && from[0] == '~') || (strncmp(from,"~/", 2) == 0)) ++ { ++#ifdef MSW ++ const char *home = getenv("USERPROFILE"); ++#else ++ const char *home = getenv("HOME"); ++#endif ++ if(home) ++ { ++ strncpy(to, home, FILENAME_MAX - 1); ++ strncat(to, from + 1, FILENAME_MAX - strlen(from) - 2); ++ } ++ } ++ else ++ strncpy(to, from, FILENAME_MAX - 1); ++#ifdef MSW ++ char buf[FILENAME_MAX]; ++ ExpandEnvironmentStrings(to, buf, FILENAME_MAX - 2); ++ strncpy(to, buf, FILENAME_MAX - 1); ++#endif ++} + /******************* Utility functions used below ******************/ + + /*! +@@ -196,9 +224,11 @@ + char *dirresult, char **nameresult, unsigned int size, int bin) + { + int fd; ++ char buf[FILENAME_MAX]; + if (strlen(dir) + strlen(name) + strlen(ext) + 4 > size) + return (-1); +- strcpy(dirresult, dir); ++ sys_expandpath(dir, buf); ++ strcpy(dirresult, buf); + if (*dirresult && dirresult[strlen(dirresult)-1] != '/') + strcat(dirresult, "/"); + strcat(dirresult, name); +@@ -250,16 +280,16 @@ + int sys_open_absolute(const char *name, const char* ext, + char *dirresult, char **nameresult, unsigned int size, int bin, int *fdp) + { +- if (name[0] == '/' ++ if (name[0] == '/' || name[0] == '~' + #ifdef MSW +- || (name[1] == ':' && name[2] == '/') ++ || name[0] == '%' || (name[1] == ':' && name[2] == '/') + #endif + ) + { +- char dirbuf[MAXPDSTRING]; ++ char dirbuf[FILENAME_MAX]; + int dirlen = (strrchr(name, '/') - name); +- if (dirlen > MAXPDSTRING-1) +- dirlen = MAXPDSTRING-1; ++ if (dirlen > FILENAME_MAX-1) ++ dirlen = FILENAME_MAX-1; + strncpy(dirbuf, name, dirlen); + dirbuf[dirlen] = 0; + *fdp = sys_trytoopenone(dirbuf, name+(dirlen+1), ext, +@@ -326,32 +356,32 @@ + search attempts. */ + void open_via_helppath(const char *name, const char *dir) + { +- char realname[MAXPDSTRING], dirbuf[MAXPDSTRING], *basename; ++ char realname[FILENAME_MAX], dirbuf[FILENAME_MAX], *basename; + /* make up a silly "dir" if none is supplied */ + const char *usedir = (*dir ? dir : "./"); + int fd; + + /* 1. "objectname-help.pd" */ +- strncpy(realname, name, MAXPDSTRING-10); +- realname[MAXPDSTRING-10] = 0; ++ strncpy(realname, name, FILENAME_MAX-10); ++ realname[FILENAME_MAX-10] = 0; + if (strlen(realname) > 3 && !strcmp(realname+strlen(realname)-3, ".pd")) + realname[strlen(realname)-3] = 0; + strcat(realname, "-help.pd"); + if ((fd = do_open_via_path(dir, realname, "", dirbuf, &basename, +- MAXPDSTRING, 0, sys_helppath)) >= 0) ++ FILENAME_MAX, 0, sys_helppath)) >= 0) + goto gotone; + + /* 2. "help-objectname.pd" */ + strcpy(realname, "help-"); +- strncat(realname, name, MAXPDSTRING-10); +- realname[MAXPDSTRING-1] = 0; ++ strncat(realname, name, FILENAME_MAX-10); ++ realname[FILENAME_MAX-1] = 0; + if ((fd = do_open_via_path(dir, realname, "", dirbuf, &basename, +- MAXPDSTRING, 0, sys_helppath)) >= 0) ++ FILENAME_MAX, 0, sys_helppath)) >= 0) + goto gotone; + + /* 3. "objectname.pd" */ + if ((fd = do_open_via_path(dir, name, "", dirbuf, &basename, +- MAXPDSTRING, 0, sys_helppath)) >= 0) ++ FILENAME_MAX, 0, sys_helppath)) >= 0) + goto gotone; + post("sorry, couldn't find help patch for "%s"", name); + return; +@@ -379,7 +409,7 @@ + int rcargc; + char* rcargv[NUMARGS]; + char* buffer; +- char fname[MAXPDSTRING], buf[1000], *home = getenv("HOME"); ++ char fname[FILENAME_MAX], buf[1000], *home = getenv("HOME"); + int retval = 1; /* that's what we will return at the end; for now, let's think it'll be an error */ + + /* initialize rc-arg-array so we can safely clean up at the end */ +@@ -391,7 +421,7 @@ + + *fname = '\0'; + +- strncat(fname, home? home : ".", MAXPDSTRING-10); ++ strncat(fname, home? home : ".", FILENAME_MAX-10); + strcat(fname, "/"); + + strcat(fname, STARTUPNAME); +Index: g_canvas.c +=================================================================== +--- g_canvas.c (revision 9725) ++++ g_canvas.c (working copy) +@@ -1543,7 +1543,6 @@ + { + t_namelist *nl, thislist; + int fd = -1; +- char listbuf[MAXPDSTRING]; + t_canvas *y; + + /* first check if "name" is absolute (and if so, try to open) */ +@@ -1563,12 +1562,12 @@ + dir = (x2 ? canvas_getdir(x2)->s_name : "."); + for (nl = y->gl_env->ce_path; nl; nl = nl->nl_next) + { +- char realname[MAXPDSTRING]; +- strncpy(realname, dir, MAXPDSTRING); +- realname[MAXPDSTRING-3] = 0; ++ char realname[FILENAME_MAX]; ++ strncpy(realname, dir, FILENAME_MAX); ++ realname[FILENAME_MAX-3] = 0; + strcat(realname, "/"); +- strncat(realname, nl->nl_string, MAXPDSTRING-strlen(realname)); +- realname[MAXPDSTRING-1] = 0; ++ strncat(realname, nl->nl_string, FILENAME_MAX-strlen(realname)); ++ realname[FILENAME_MAX-1] = 0; + if ((fd = sys_trytoopenone(realname, name, ext, + dirresult, nameresult, size, bin)) >= 0) + return (fd); +Index: s_loader.c +=================================================================== +--- s_loader.c (revision 9725) ++++ s_loader.c (working copy) +@@ -86,7 +86,7 @@ + + static int sys_do_load_lib(t_canvas *canvas, char *objectname) + { +- char symname[MAXPDSTRING], filename[MAXPDSTRING], dirbuf[MAXPDSTRING], ++ char symname[MAXPDSTRING], filename[FILENAME_MAX], dirbuf[FILENAME_MAX], + *classname, *nameptr, altsymname[MAXPDSTRING]; + void *dlobj; + t_xxx makeout = NULL; +@@ -137,23 +137,23 @@ + #endif + /* try looking in the path for (objectname).(sys_dllextent) ... */ + if ((fd = canvas_open(canvas, objectname, sys_dllextent, +- dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) ++ dirbuf, &nameptr, FILENAME_MAX, 1)) >= 0) + goto gotone; + /* same, with the more generic sys_dllextent2 */ + if ((fd = canvas_open(canvas, objectname, sys_dllextent2, +- dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) ++ dirbuf, &nameptr, FILENAME_MAX, 1)) >= 0) + goto gotone; + /* next try (objectname)/(classname).(sys_dllextent) ... */ +- strncpy(filename, objectname, MAXPDSTRING); ++ strncpy(filename, objectname, FILENAME_MAX); + filename[MAXPDSTRING-2] = 0; + strcat(filename, "/"); +- strncat(filename, classname, MAXPDSTRING-strlen(filename)); +- filename[MAXPDSTRING-1] = 0; ++ strncat(filename, classname, FILENAME_MAX-strlen(filename)); ++ filename[FILENAME_MAX-1] = 0; + if ((fd = canvas_open(canvas, filename, sys_dllextent, +- dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) ++ dirbuf, &nameptr, FILENAME_MAX, 1)) >= 0) + goto gotone; + if ((fd = canvas_open(canvas, filename, sys_dllextent2, +- dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) ++ dirbuf, &nameptr, FILENAME_MAX, 1)) >= 0) + goto gotone; + return (0); + gotone: +@@ -161,11 +161,11 @@ + class_set_extern_dir(gensym(dirbuf)); + + /* rebuild the absolute pathname */ +- strncpy(filename, dirbuf, MAXPDSTRING); +- filename[MAXPDSTRING-2] = 0; ++ strncpy(filename, dirbuf, FILENAME_MAX); ++ filename[FILENAME_MAX-2] = 0; + strcat(filename, "/"); +- strncat(filename, nameptr, MAXPDSTRING-strlen(filename)); +- filename[MAXPDSTRING-1] = 0; ++ strncat(filename, nameptr, FILENAME_MAX-strlen(filename)); ++ filename[FILENAME_MAX-1] = 0; + + #ifdef DL_OPEN + dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL); +Index: m_binbuf.c +=================================================================== +--- m_binbuf.c (revision 9725) ++++ m_binbuf.c (working copy) +@@ -740,7 +740,7 @@ + + static int binbuf_doopen(char *s, int mode) + { +- char namebuf[MAXPDSTRING]; ++ char namebuf[FILENAME_MAX]; + #ifdef MSW + mode |= O_BINARY; + #endif +@@ -750,7 +750,7 @@ + + static FILE *binbuf_dofopen(char *s, char *mode) + { +- char namebuf[MAXPDSTRING]; ++ char namebuf[FILENAME_MAX]; + sys_bashfilename(s, namebuf); + return (fopen(namebuf, mode)); + } +@@ -761,7 +761,7 @@ + int fd; + int readret; + char *buf; +- char namebuf[MAXPDSTRING]; ++ char namebuf[FILENAME_MAX]; + + namebuf[0] = 0; + if (*dirname) +@@ -814,9 +814,9 @@ + int crflag) + { + int filedesc; +- char buf[MAXPDSTRING], *bufptr; ++ char buf[FILENAME_MAX], *bufptr; + if ((filedesc = canvas_open(canvas, filename, "", +- buf, &bufptr, MAXPDSTRING, 0)) < 0) ++ buf, &bufptr, FILENAME_MAX, 0)) < 0) + { + error("%s: can't open", filename); + return (1); +@@ -832,9 +832,9 @@ + int crflag) + { + int filedesc; +- char buf[MAXPDSTRING], *bufptr; ++ char buf[FILENAME_MAX], *bufptr; + if ((filedesc = open_via_path( +- dirname, filename, "", buf, &bufptr, MAXPDSTRING, 0)) < 0) ++ dirname, filename, "", buf, &bufptr, FILENAME_MAX, 0)) < 0) + { + error("%s: can't open", filename); + return (1); +@@ -853,7 +853,7 @@ + int binbuf_write(t_binbuf *x, char *filename, char *dir, int crflag) + { + FILE *f = 0; +- char sbuf[WBUFSIZE], fbuf[MAXPDSTRING], *bp = sbuf, *ep = sbuf + WBUFSIZE; ++ char sbuf[WBUFSIZE], fbuf[FILENAME_MAX], *bp = sbuf, *ep = sbuf + WBUFSIZE; + t_atom *ap; + int indx, deleteit = 0; + int ncolumn = 0; +Index: d_soundfile.c +=================================================================== +--- d_soundfile.c (revision 9725) ++++ d_soundfile.c (working copy) +@@ -400,9 +400,9 @@ + int *p_bytespersamp, int *p_bigendian, int *p_nchannels, long *p_bytelimit, + long skipframes) + { +- char buf[OBUFSIZE], *bufptr; ++ char buf[FILENAME_MAX], *bufptr; + int fd; +- fd = open_via_path(dirname, filename, "", buf, &bufptr, MAXPDSTRING, 1); ++ fd = open_via_path(dirname, filename, "", buf, &bufptr, FILENAME_MAX, 1); + if (fd < 0) + return (-1); + else return (open_soundfile_via_fd(fd, headersize, p_bytespersamp, +@@ -416,9 +416,9 @@ + int *p_bytespersamp, int *p_bigendian, int *p_nchannels, long *p_bytelimit, + long skipframes) + { +- char buf[OBUFSIZE], *bufptr; ++ char buf[FILENAME_MAX], *bufptr; + int fd; +- fd = canvas_open(canvas, filename, "", buf, &bufptr, MAXPDSTRING, 1); ++ fd = canvas_open(canvas, filename, "", buf, &bufptr, FILENAME_MAX, 1); + if (fd < 0) + return (-1); + else return (open_soundfile_via_fd(fd, headersize, p_bytespersamp, +@@ -738,15 +738,15 @@ + int filetype, int nframes, int bytespersamp, + int bigendian, int nchannels, int swap, t_float samplerate) + { +- char filenamebuf[MAXPDSTRING], buf2[MAXPDSTRING]; ++ char filenamebuf[FILENAME_MAX], buf2[FILENAME_MAX]; + char headerbuf[WRITEHDRSIZE]; + t_wave *wavehdr = (t_wave *)headerbuf; + t_nextstep *nexthdr = (t_nextstep *)headerbuf; + t_aiff *aiffhdr = (t_aiff *)headerbuf; + int fd, headersize = 0; + +- strncpy(filenamebuf, filename, MAXPDSTRING-10); +- filenamebuf[MAXPDSTRING-10] = 0; ++ strncpy(filenamebuf, filename, FILENAME_MAX-10); ++ filenamebuf[FILENAME_MAX-10] = 0; + + if (filetype == FORMAT_NEXT) + { +@@ -812,7 +812,7 @@ + headersize = sizeof(t_wave); + } + +- canvas_makefilename(canvas, filenamebuf, buf2, MAXPDSTRING); ++ canvas_makefilename(canvas, filenamebuf, buf2, FILENAME_MAX); + sys_bashfilename(buf2, buf2); + if ((fd = open(buf2, BINCREATE, 0666)) < 0) + return (-1); +Index: m_class.c +=================================================================== +--- m_class.c (revision 9725) ++++ m_class.c (working copy) +@@ -498,7 +498,7 @@ + + static t_symbol *addfileextent(t_symbol *s) + { +- char namebuf[MAXPDSTRING], *str = s->s_name; ++ char namebuf[FILENAME_MAX], *str = s->s_name; + int ln = strlen(str); + if (!strcmp(str + ln - 3, ".pd")) return (s); + strcpy(namebuf, str); +@@ -520,7 +520,7 @@ + { + t_pd *current; + int fd; +- char dirbuf[MAXPDSTRING], *nameptr; ++ char dirbuf[FILENAME_MAX], *nameptr; + if (tryingalready) return; + newest = 0; + class_loadsym = s; +@@ -534,9 +534,9 @@ + class_loadsym = 0; + current = s__X.s_thing; + if ((fd = canvas_open(canvas_getcurrent(), s->s_name, ".pd", +- dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0 || ++ dirbuf, &nameptr, FILENAME_MAX, 0)) >= 0 || + (fd = canvas_open(canvas_getcurrent(), s->s_name, ".pat", +- dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0) ++ dirbuf, &nameptr, FILENAME_MAX, 0)) >= 0) + { + close (fd); + if (!pd_setloadingabstraction(s)) +Index: g_array.c +=================================================================== +--- g_array.c (revision 9725) ++++ g_array.c (working copy) +@@ -1384,7 +1384,7 @@ + { + int nelem, filedesc, i; + FILE *fd; +- char buf[MAXPDSTRING], *bufptr; ++ char buf[FILENAME_MAX], *bufptr; + int yonset, elemsize; + t_array *array = garray_getarray_floatonly(x, &yonset, &elemsize); + if (!array) +@@ -1394,7 +1394,7 @@ + } + nelem = array->a_n; + if ((filedesc = canvas_open(glist_getcanvas(x->x_glist), +- filename->s_name, "", buf, &bufptr, MAXPDSTRING, 0)) < 0 ++ filename->s_name, "", buf, &bufptr, FILENAME_MAX, 0)) < 0 + || !(fd = fdopen(filedesc, "r"))) + { + error("%s: can't open", filename->s_name);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.