Althttpd

Check-in [39ba92dd0a]
Login

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

Overview
Comment:Start the kill timer *before* starting up OpenSSL.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 39ba92dd0adc017741834d77973b253c4143cb6836823c31bb1063ebbe81705a
User & Date: drh 2022-03-03 19:15:11.821
Context
2022-03-04
13:11
Improved log-file reporting of timeouts. Fix timeouts on large file downloads (see https://sqlite.org/forum/forumpost/52b0627b6925.) Fix the log-file error line-number database. ... (check-in: 188a2625d4 user: drh tags: trunk)
2022-03-03
19:15
Start the kill timer *before* starting up OpenSSL. ... (check-in: 39ba92dd0a user: drh tags: trunk)
17:05
Even after a single successful HTTP request, still impose a 4-hour timeout on subsequent requests. ... (check-in: a0a3f858f5 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to althttpd.c.
2210
2211
2212
2213
2214
2215
2216




2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
  struct stat statbuf;      /* Information about the file to be retrieved */
  FILE *in;                 /* For reading from CGI scripts */
#ifdef LOG_HEADER
  FILE *hdrLog = 0;         /* Log file for complete header content */
#endif
  char zLine[1000];         /* A buffer for input lines or forming names */





  /* Change directories to the root of the HTTP filesystem
  */
  if( chdir(zRoot[0] ? zRoot : "/")!=0 ){
    char zBuf[1000];
    Malfunction(190,   /* LOG: chdir() failed */
         "cannot chdir to [%s] from [%s]",
         zRoot, getcwd(zBuf,sizeof(zBuf)-1));
  }
  nRequest++;
  tls_init_conn(socketId);
  /*
  ** We must receive a complete header within 15 seconds
  */
  signal(SIGALRM, Timeout);
  signal(SIGSEGV, Timeout);
  signal(SIGPIPE, Timeout);
  signal(SIGXCPU, Timeout);
  if( useTimeout ) alarm(15);

  /* Get the first line of the request and parse out the
  ** method, the script and the protocol.
  */
  omitLog = 1;
  if( althttpd_fgets(zLine,sizeof(zLine),stdin)==0 ){
    exit(0);







>
>
>
>










<
<
<
<
<
<
<
<







2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230








2231
2232
2233
2234
2235
2236
2237
  struct stat statbuf;      /* Information about the file to be retrieved */
  FILE *in;                 /* For reading from CGI scripts */
#ifdef LOG_HEADER
  FILE *hdrLog = 0;         /* Log file for complete header content */
#endif
  char zLine[1000];         /* A buffer for input lines or forming names */


  /* Must a header within 10 seconds */
  if( useTimeout ) alarm(10);

  /* Change directories to the root of the HTTP filesystem
  */
  if( chdir(zRoot[0] ? zRoot : "/")!=0 ){
    char zBuf[1000];
    Malfunction(190,   /* LOG: chdir() failed */
         "cannot chdir to [%s] from [%s]",
         zRoot, getcwd(zBuf,sizeof(zBuf)-1));
  }
  nRequest++;
  tls_init_conn(socketId);









  /* Get the first line of the request and parse out the
  ** method, the script and the protocol.
  */
  omitLog = 1;
  if( althttpd_fgets(zLine,sizeof(zLine),stdin)==0 ){
    exit(0);
3023
3024
3025
3026
3027
3028
3029









3030
3031
3032
3033
3034
3035
3036
      zRoot = ".";
    }else{
      Malfunction(516, /* LOG: --root argument missing */
                  "no --root specified");
    }
  }










#if ENABLE_TLS
  /* We "need" to read the cert before chroot'ing to allow that the
  ** cert is stored in space outside of the --root and not readable by
  ** the --user.
  */
  if( useHttps>=2 ){
    ssl_init_server(tlsState.zCertFile, tlsState.zKeyFile);







>
>
>
>
>
>
>
>
>







3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
      zRoot = ".";
    }else{
      Malfunction(516, /* LOG: --root argument missing */
                  "no --root specified");
    }
  }

  /*
  ** 10 seconds to get started
  */
  signal(SIGALRM, Timeout);
  signal(SIGSEGV, Timeout);
  signal(SIGPIPE, Timeout);
  signal(SIGXCPU, Timeout);
  if( useTimeout ) alarm(10);

#if ENABLE_TLS
  /* We "need" to read the cert before chroot'ing to allow that the
  ** cert is stored in space outside of the --root and not readable by
  ** the --user.
  */
  if( useHttps>=2 ){
    ssl_init_server(tlsState.zCertFile, tlsState.zKeyFile);