home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 May / PC_ONLINE_5_99.ISO / filesbbs / linux / proftpd-1_2_0pre1-path_exploit2.patch < prev    next >
Encoding:
Text File  |  1999-03-24  |  3.8 KB  |  140 lines

  1. diff -ru proftpd-1.2.0pre1.orig/include/support.h proftpd-1.2.0pre1/include/support.h
  2. --- proftpd-1.2.0pre1.orig/include/support.h    Sat Oct 17 22:24:41 1998
  3. +++ proftpd-1.2.0pre1/include/support.h    Thu Feb 11 12:33:31 1999
  4. @@ -75,6 +75,7 @@
  5.  char *safe_token(char**);
  6.  int check_shutmsg(time_t*,time_t*,time_t*,char*,size_t);
  7.  
  8. +char *sstrcat(char *dest, const char *src, size_t n);
  9.  char *sreplace(pool*,char*,...);
  10.  
  11.  #if defined(HAVE_SYS_STATVFS_H) || defined(HAVE_SYS_VFS_H)
  12. diff -ru proftpd-1.2.0pre1.orig/src/fs.c proftpd-1.2.0pre1/src/fs.c
  13. --- proftpd-1.2.0pre1.orig/src/fs.c    Sat Oct 17 22:24:41 1998
  14. +++ proftpd-1.2.0pre1/src/fs.c    Thu Feb 11 12:36:58 1999
  15. @@ -351,9 +351,9 @@
  16.  
  17.    strcpy(buf,_dir1);
  18.    if(i && *(_dir1+i) != '/')
  19. -    strcat(buf,"/");
  20. +    sstrcat(buf,"/",MAXPATHLEN);
  21.  
  22. -  strcat(buf,_dir2);
  23. +  sstrcat(buf,_dir2,MAXPATHLEN);
  24.  
  25.    if(!*buf) {
  26.     *buf++ = '/';
  27. @@ -485,11 +485,11 @@
  28.        if(*namebuf) {
  29.          for(last = namebuf; *last; last++) ;
  30.          if(*--last != '/')
  31. -          strcat(namebuf,"/");
  32. +          sstrcat(namebuf,"/",MAXPATHLEN);
  33.        } else
  34. -        strcat(namebuf,"/");
  35. +        sstrcat(namebuf,"/",MAXPATHLEN);
  36.  
  37. -      strcat(namebuf,where);
  38. +      sstrcat(namebuf,where,MAXPATHLEN);
  39.  
  40.        where = ++ptr;
  41.  
  42. @@ -530,8 +530,8 @@
  43.            fs_interpolate(tmpbuf,linkpath,sizeof(linkpath));
  44.          }
  45.          if(*where) {
  46. -          strcat(linkpath,"/");
  47. -          strcat(linkpath,where);
  48. +          sstrcat(linkpath,"/",MAXPATHLEN);
  49. +          sstrcat(linkpath,where,MAXPATHLEN);
  50.          }
  51.          strcpy(curpath,linkpath);
  52.          fini++;
  53. @@ -621,11 +621,11 @@
  54.        if(*namebuf) {
  55.          for(last = namebuf; *last; last++) ;
  56.          if(*--last != '/')
  57. -          strcat(namebuf,"/");
  58. +          sstrcat(namebuf,"/",MAXPATHLEN);
  59.        } else
  60. -        strcat(namebuf,"/");
  61. +        sstrcat(namebuf,"/",MAXPATHLEN);
  62.  
  63. -      strcat(namebuf,where);
  64. +      sstrcat(namebuf,where,MAXPATHLEN);
  65.  
  66.        where = ++ptr;
  67.  
  68. @@ -666,8 +666,8 @@
  69.            fs_interpolate(tmpbuf,linkpath,sizeof(linkpath));
  70.          }
  71.          if(*where) {
  72. -          strcat(linkpath,"/");
  73. -          strcat(linkpath,where);
  74. +          sstrcat(linkpath,"/",MAXPATHLEN);
  75. +          sstrcat(linkpath,where,MAXPATHLEN);
  76.          }
  77.          strcpy(curpath,linkpath);
  78.          fini++;
  79. @@ -754,15 +754,17 @@
  80.        else
  81.          *ptr = '\0';
  82.  
  83. -      strcpy(namebuf,workpath);
  84. +      strncpy(namebuf,workpath,MAXPATHLEN);
  85. +      namebuf[MAXPATHLEN-1] = '\0';
  86. +      
  87.        if(*namebuf) {
  88.          for(last = namebuf; *last; last++) ;
  89.          if(*--last != '/')
  90. -          strcat(namebuf,"/");
  91. +          sstrcat(namebuf,"/",MAXPATHLEN);
  92.        } else
  93. -        strcat(namebuf,"/");
  94. +        sstrcat(namebuf,"/",MAXPATHLEN);
  95.  
  96. -      strcat(namebuf,where);
  97. +      sstrcat(namebuf,where,MAXPATHLEN);
  98.  
  99.        where = ++ptr;
  100.  
  101. @@ -851,11 +853,11 @@
  102.        if(*namebuf) {
  103.          for(last = namebuf; *last; last++) ;
  104.          if(*--last != '/')
  105. -          strcat(namebuf,"/");
  106. +          sstrcat(namebuf,"/",MAXPATHLEN);
  107.        } else
  108. -        strcat(namebuf,"/");
  109. +        sstrcat(namebuf,"/",MAXPATHLEN);
  110.  
  111. -      strcat(namebuf,where);
  112. +      sstrcat(namebuf,where,MAXPATHLEN);
  113.  
  114.        where = ++ptr;
  115.  
  116. diff -ru proftpd-1.2.0pre1.orig/src/support.c proftpd-1.2.0pre1/src/support.c
  117. --- proftpd-1.2.0pre1.orig/src/support.c    Sat Oct 17 22:24:41 1998
  118. +++ proftpd-1.2.0pre1/src/support.c    Thu Feb 11 12:33:31 1999
  119. @@ -665,3 +665,20 @@
  120.    return _calc_fs(vfs.f_bavail,vfs.f_bsize);
  121.  }
  122.  #endif /* HAVE_SYS_STATVFS/HAVE_SYS_VFS */
  123. +
  124. +/* "safe" strcat, saves room for \0 at end of dest, and refuses to copy
  125. + * more than "n" bytes.
  126. + */
  127. +
  128. +char *sstrcat(char *dest, const char *src, size_t n)
  129. +{
  130. +    register char *d;
  131. +
  132. +    for(d = dest; *d && n > 1; d++, n--) ;
  133. +
  134. +    while(n-- > 1 && *src)
  135. +        *d++ = *src++;
  136. +    
  137. +    *d = 0;
  138. +    return dest;
  139. +}
  140.