You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by Randy Terbush <ra...@hyperreal.com> on 1997/01/01 00:28:45 UTC

cvs commit: apache/support suexec.c

randy       96/12/31 15:28:45

  Modified:    support   suexec.c
  Log:
  Don't free() memory that was not malloc'ed.
  
  Revision  Changes    Path
  1.9       +2 -11     apache/support/suexec.c
  
  Index: suexec.c
  ===================================================================
  RCS file: /export/home/cvs/apache/support/suexec.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -C3 -r1.8 -r1.9
  *** suexec.c	1996/12/27 22:21:23	1.8
  --- suexec.c	1996/12/31 23:28:43	1.9
  ***************
  *** 214,221 ****
         * ~userdir request.  Error out if we cannot get either one,
         * or if the current working directory is not in the docroot.
         * Use chdir()s and getcwd()s to avoid problems with symlinked
  !      * directories.  Yuck.  NOTE: We also free() dwd since it is
  !      * the last usage...
         */
        if (getcwd(cwd, MAXPATHLEN) == NULL) {
            log_err("cannot get current working directory\n");
  --- 214,220 ----
         * ~userdir request.  Error out if we cannot get either one,
         * or if the current working directory is not in the docroot.
         * Use chdir()s and getcwd()s to avoid problems with symlinked
  !      * directories.  Yuck.
         */
        if (getcwd(cwd, MAXPATHLEN) == NULL) {
            log_err("cannot get current working directory\n");
  ***************
  *** 242,267 ****
        }
        
        doclen = strlen(dwd);
  !     if (strncmp(cwd, dwd, doclen) != 0) {
  !         free(dwd);
            log_err("command not in docroot (%s/%s)\n", cwd, cmd);
            exit(109);
        }
  -     else
  -         free(dwd);
  - 
    
        /*
         * Stat the cwd and verify it is a directory, or error out.
  -      * NOTE: This is the last use of cwd, so we must free() it.
         */
        if (((lstat(cwd, &dir_info)) != 0) || !(S_ISDIR(dir_info.st_mode))) {
  -         free(cwd);
    	log_err("cannot stat directory: (%s)\n", cwd);
    	exit(110);
        }
  -     else
  -         free(cwd);
    
        /*
         * Error out if cwd is writable by others.
  --- 241,258 ----
        }
        
        doclen = strlen(dwd);
  !     if ((strncmp(cwd, dwd, doclen)) != 0) {
            log_err("command not in docroot (%s/%s)\n", cwd, cmd);
            exit(109);
        }
    
        /*
         * Stat the cwd and verify it is a directory, or error out.
         */
        if (((lstat(cwd, &dir_info)) != 0) || !(S_ISDIR(dir_info.st_mode))) {
    	log_err("cannot stat directory: (%s)\n", cwd);
    	exit(110);
        }
    
        /*
         * Error out if cwd is writable by others.