Fossil

Check-in [35ab16bc9e]
Login

Check-in [35ab16bc9e]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Put the output into CGI or inetd mode prior to failing with a "file-descriptor 2 not open" error.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 35ab16bc9e0f33154a1a7464a8edf3c85e11fd5b
User & Date: drh 2015-02-07 20:40:24.581
Context
2015-02-07
21:14
Further improvements to the defenses against being invoked without file descriptor 2 being open. ... (check-in: 6dbaa67420 user: drh tags: trunk)
20:40
Put the output into CGI or inetd mode prior to failing with a "file-descriptor 2 not open" error. ... (check-in: 35ab16bc9e user: drh tags: trunk)
19:52
Off-by-one error in the previous commit. ... (check-in: 478ef4ca5a user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/main.c.
691
692
693
694
695
696
697



698
699
700
701
702
703
704
    zCmdName = g.argv[1];
  }
#ifndef _WIN32
  /* Make sure open() will not return file descriptor 2. */
  { int nTry = 0;
    while( !is_valid_fd(2) && nTry++ < 2 && open("/dev/null",O_WRONLY)>=0 ){}
    if( !is_valid_fd(2) ){



      fossil_fatal("file descriptor 2 is not open");
    }
  }
#endif
  rc = name_search(zCmdName, aCommand, count(aCommand), FOSSIL_FIRST_CMD, &idx);
  if( rc==1 ){
#ifdef FOSSIL_ENABLE_TH1_HOOKS







>
>
>







691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
    zCmdName = g.argv[1];
  }
#ifndef _WIN32
  /* Make sure open() will not return file descriptor 2. */
  { int nTry = 0;
    while( !is_valid_fd(2) && nTry++ < 2 && open("/dev/null",O_WRONLY)>=0 ){}
    if( !is_valid_fd(2) ){
      g.cgiOutput = 1;
      g.httpOut = stdout;
      g.fullHttpReply = !g.isHTTP;
      fossil_fatal("file descriptor 2 is not open");
    }
  }
#endif
  rc = name_search(zCmdName, aCommand, count(aCommand), FOSSIL_FIRST_CMD, &idx);
  if( rc==1 ){
#ifdef FOSSIL_ENABLE_TH1_HOOKS