From 6ed457e0621cf05bb6150ba27de0438f34194061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Thu, 30 Apr 2015 20:07:26 +0000 Subject: use canvas_open() and use filenames for sf_open() rather than passing around the fd returned by canvas_open, as this is insecure/incompatible on W32 svn path=/trunk/externals/iem/iemmatrix/; revision=17459 --- src/mtx_sndfileread.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/mtx_sndfileread.c b/src/mtx_sndfileread.c index 3a8f252..9e88e2c 100644 --- a/src/mtx_sndfileread.c +++ b/src/mtx_sndfileread.c @@ -141,19 +141,21 @@ static void mtx_sndfileread_open (t_mtx_sndfileread *x, t_symbol *s, t_symbol*ty { #ifdef HAVE_SNDFILE_H char filenamebuf[MAXPDSTRING], *filenamebufptr; - char*dirname=canvas_getdir(x->x_canvas)->s_name; int fd; mtx_sndfileread_close(x); /* directory, filename, extension, dirresult, nameresult, unsigned int size, int bin */ - if ((fd=open_via_path(dirname, - s->s_name,"", filenamebuf, &filenamebufptr, MAXPDSTRING,0)) < 0 ) { - pd_error(x, "%s: failed to open %s", s->s_name, filenamebuf); + fd=canvas_open(x->x_canvas, s->s_name, "", filenamebuf, &filenamebufptr, MAXPDSTRING, 1); + if(fd<0){ + pd_error(x, "failed to open %s : %s", s->s_name, filenamebuf); return; } - if (!(x->x_sndfileread = sf_open_fd (fd, SFM_READ, &x->x_sfinfo, 1))) { - pd_error(x, "%s: failed to sfopen %s", s->s_name, filenamebuf); + iemmatrix_fdclose(fd); + if(!filenamebufptr[-1]) + filenamebufptr[-1]='/'; + if (!(x->x_sndfileread = sf_open (filenamebuf, SFM_READ, &x->x_sfinfo))) { + pd_error(x, "failed to sfopen %s : %s", s->s_name, filenamebuf); mtx_sndfileread_close(x); return; } -- cgit v1.2.1