home *** CD-ROM | disk | FTP | other *** search
- diff -ru proftpd-1.2.0pre1.orig/include/support.h proftpd-1.2.0pre1/include/support.h
- --- proftpd-1.2.0pre1.orig/include/support.h Sat Oct 17 22:24:41 1998
- +++ proftpd-1.2.0pre1/include/support.h Thu Feb 11 12:33:31 1999
- @@ -75,6 +75,7 @@
- char *safe_token(char**);
- int check_shutmsg(time_t*,time_t*,time_t*,char*,size_t);
-
- +char *sstrcat(char *dest, const char *src, size_t n);
- char *sreplace(pool*,char*,...);
-
- #if defined(HAVE_SYS_STATVFS_H) || defined(HAVE_SYS_VFS_H)
- diff -ru proftpd-1.2.0pre1.orig/src/fs.c proftpd-1.2.0pre1/src/fs.c
- --- proftpd-1.2.0pre1.orig/src/fs.c Sat Oct 17 22:24:41 1998
- +++ proftpd-1.2.0pre1/src/fs.c Thu Feb 11 12:36:58 1999
- @@ -351,9 +351,9 @@
-
- strcpy(buf,_dir1);
- if(i && *(_dir1+i) != '/')
- - strcat(buf,"/");
- + sstrcat(buf,"/",MAXPATHLEN);
-
- - strcat(buf,_dir2);
- + sstrcat(buf,_dir2,MAXPATHLEN);
-
- if(!*buf) {
- *buf++ = '/';
- @@ -485,11 +485,11 @@
- if(*namebuf) {
- for(last = namebuf; *last; last++) ;
- if(*--last != '/')
- - strcat(namebuf,"/");
- + sstrcat(namebuf,"/",MAXPATHLEN);
- } else
- - strcat(namebuf,"/");
- + sstrcat(namebuf,"/",MAXPATHLEN);
-
- - strcat(namebuf,where);
- + sstrcat(namebuf,where,MAXPATHLEN);
-
- where = ++ptr;
-
- @@ -530,8 +530,8 @@
- fs_interpolate(tmpbuf,linkpath,sizeof(linkpath));
- }
- if(*where) {
- - strcat(linkpath,"/");
- - strcat(linkpath,where);
- + sstrcat(linkpath,"/",MAXPATHLEN);
- + sstrcat(linkpath,where,MAXPATHLEN);
- }
- strcpy(curpath,linkpath);
- fini++;
- @@ -621,11 +621,11 @@
- if(*namebuf) {
- for(last = namebuf; *last; last++) ;
- if(*--last != '/')
- - strcat(namebuf,"/");
- + sstrcat(namebuf,"/",MAXPATHLEN);
- } else
- - strcat(namebuf,"/");
- + sstrcat(namebuf,"/",MAXPATHLEN);
-
- - strcat(namebuf,where);
- + sstrcat(namebuf,where,MAXPATHLEN);
-
- where = ++ptr;
-
- @@ -666,8 +666,8 @@
- fs_interpolate(tmpbuf,linkpath,sizeof(linkpath));
- }
- if(*where) {
- - strcat(linkpath,"/");
- - strcat(linkpath,where);
- + sstrcat(linkpath,"/",MAXPATHLEN);
- + sstrcat(linkpath,where,MAXPATHLEN);
- }
- strcpy(curpath,linkpath);
- fini++;
- @@ -754,15 +754,17 @@
- else
- *ptr = '\0';
-
- - strcpy(namebuf,workpath);
- + strncpy(namebuf,workpath,MAXPATHLEN);
- + namebuf[MAXPATHLEN-1] = '\0';
- +
- if(*namebuf) {
- for(last = namebuf; *last; last++) ;
- if(*--last != '/')
- - strcat(namebuf,"/");
- + sstrcat(namebuf,"/",MAXPATHLEN);
- } else
- - strcat(namebuf,"/");
- + sstrcat(namebuf,"/",MAXPATHLEN);
-
- - strcat(namebuf,where);
- + sstrcat(namebuf,where,MAXPATHLEN);
-
- where = ++ptr;
-
- @@ -851,11 +853,11 @@
- if(*namebuf) {
- for(last = namebuf; *last; last++) ;
- if(*--last != '/')
- - strcat(namebuf,"/");
- + sstrcat(namebuf,"/",MAXPATHLEN);
- } else
- - strcat(namebuf,"/");
- + sstrcat(namebuf,"/",MAXPATHLEN);
-
- - strcat(namebuf,where);
- + sstrcat(namebuf,where,MAXPATHLEN);
-
- where = ++ptr;
-
- diff -ru proftpd-1.2.0pre1.orig/src/support.c proftpd-1.2.0pre1/src/support.c
- --- proftpd-1.2.0pre1.orig/src/support.c Sat Oct 17 22:24:41 1998
- +++ proftpd-1.2.0pre1/src/support.c Thu Feb 11 12:33:31 1999
- @@ -665,3 +665,20 @@
- return _calc_fs(vfs.f_bavail,vfs.f_bsize);
- }
- #endif /* HAVE_SYS_STATVFS/HAVE_SYS_VFS */
- +
- +/* "safe" strcat, saves room for \0 at end of dest, and refuses to copy
- + * more than "n" bytes.
- + */
- +
- +char *sstrcat(char *dest, const char *src, size_t n)
- +{
- + register char *d;
- +
- + for(d = dest; *d && n > 1; d++, n--) ;
- +
- + while(n-- > 1 && *src)
- + *d++ = *src++;
- +
- + *d = 0;
- + return dest;
- +}
-