From 926ef67c05ec7dcea9c7b1c8a34fb493f83fdbc9 Mon Sep 17 00:00:00 2001 From: deuce <> Date: Wed, 23 Aug 2006 23:56:28 +0000 Subject: [PATCH] More fixes for removecase() - Don't allow ? or * in the path - Various bug-fixes --- src/xpdev/dirwrap.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/xpdev/dirwrap.c b/src/xpdev/dirwrap.c index 353bdd658a..55e4bfc422 100644 --- a/src/xpdev/dirwrap.c +++ b/src/xpdev/dirwrap.c @@ -573,7 +573,7 @@ BOOL DLLCALL fexistcase(char *path) #endif } -#ifndef _WIN32 +#ifdef __unix__ int removecase(char *path) { char inpath[MAX_PATH+1]; @@ -581,20 +581,22 @@ int removecase(char *path) char tmp[5]; char *p; int i; - + + if(strchr(path,'?') || strchr(path,'*')) + return(-1); SAFECOPY(inpath,path); p=getfname(inpath); - SAFECOPY(fname,p); - *p=0; + if(p>inpath) + *(p-1)=0; fname[0]=0; - p++; - for(;*p;p++) { - if(isalpha(*p)) - sprintf(tmp,"[%c%c]",toupper(*p),tolower(*p)); + for(i=0;p[i];i++) { + if(isalpha(p[i])) + sprintf(tmp,"[%c%c]",toupper(p[i]),tolower(p[i])); else - sprintf(tmp,"%c",*p); + sprintf(tmp,"%c",p[i]); strncat(fname,tmp,MAX_PATH*4); } + *p=0; return(delfiles(inpath,fname)?-1:0); } -- GitLab