Althttpd

Check-in [a1edcf8c37]
Login

Check-in [a1edcf8c37]

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

Overview
Comment:After parsing a single valid HTTP request, disable all subsequent timeoutes. See SQLite Forum post 52b0627b69 for the rationale behind this change.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a1edcf8c37ff906bd0180317895d3a612a676f2b23982917437104d1d77f1504
User & Date: drh 2022-02-24 18:25:45
Context
2022-03-03
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)
2022-02-24
18:25
After parsing a single valid HTTP request, disable all subsequent timeoutes. See SQLite Forum post 52b0627b69 for the rationale behind this change. ... (check-in: a1edcf8c37 user: drh tags: trunk)
2022-02-16
19:03
Add the static-ssl.mk makefile ... (check-in: 8763e96e91 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to althttpd.c.

2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
    zPostData = SafeMalloc( len+1 );
    if( useTimeout ) alarm(15 + len/2000);
    nPostData = althttpd_fread(zPostData,1,len,stdin);
    nIn += nPostData;
  }

  /* Make sure the running time is not too great */
  if( useTimeout ) alarm(10);

  /* Convert all unusual characters in the script name into "_".
  **
  ** This is a defense against various attacks, XSS attacks in particular.
  */
  sanitizeString(zScript);








|







2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
    zPostData = SafeMalloc( len+1 );
    if( useTimeout ) alarm(15 + len/2000);
    nPostData = althttpd_fread(zPostData,1,len,stdin);
    nIn += nPostData;
  }

  /* Make sure the running time is not too great */
  if( useTimeout ) alarm(30);

  /* Convert all unusual characters in the script name into "_".
  **
  ** This is a defense against various attacks, XSS attacks in particular.
  */
  sanitizeString(zScript);

2645
2646
2647
2648
2649
2650
2651




2652
2653
2654
2655
2656
2657
2658
  ** process it.
  */
  sprintf(zLine, "%s/-auth", zDir);
  if( access(zLine,R_OK)==0 && !CheckBasicAuthorization(zLine) ){
    tls_close_conn();
    return;
  }





  /* Take appropriate action
  */
  if( (statbuf.st_mode & 0100)==0100 && access(zFile,X_OK)==0 ){ /* CGI */
    char *zBaseFilename;       /* Filename without directory prefix */
    int px[2];                 /* CGI-1 to althttpd pipe */
    int py[2];                 /* zPostData to CGI-0 pipe */







>
>
>
>







2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
  ** process it.
  */
  sprintf(zLine, "%s/-auth", zDir);
  if( access(zLine,R_OK)==0 && !CheckBasicAuthorization(zLine) ){
    tls_close_conn();
    return;
  }

  /* After parsing a single successful request.  Disable subsequent timeouts */
  alarm(0);
  useTimeout = 0;

  /* Take appropriate action
  */
  if( (statbuf.st_mode & 0100)==0100 && access(zFile,X_OK)==0 ){ /* CGI */
    char *zBaseFilename;       /* Filename without directory prefix */
    int px[2];                 /* CGI-1 to althttpd pipe */
    int py[2];                 /* zPostData to CGI-0 pipe */
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
    */
    if( SendFile(zFile, lenFile, &statbuf) ){
      return;
    }
  }
  althttpd_fflush(stdout);
  MakeLogEntry(0, 0);  /* LOG: Normal reply */

  /* The next request must arrive within 30 seconds or we close the connection
  */
  omitLog = 1;
  if( useTimeout ) alarm(30);
}

#define MAX_PARALLEL 50  /* Number of simultaneous children */

/*
** All possible forms of an IP address.  Needed to work around GCC strict
** aliasing rules.







<
<
<

<







2771
2772
2773
2774
2775
2776
2777



2778

2779
2780
2781
2782
2783
2784
2785
    */
    if( SendFile(zFile, lenFile, &statbuf) ){
      return;
    }
  }
  althttpd_fflush(stdout);
  MakeLogEntry(0, 0);  /* LOG: Normal reply */



  omitLog = 1;

}

#define MAX_PARALLEL 50  /* Number of simultaneous children */

/*
** All possible forms of an IP address.  Needed to work around GCC strict
** aliasing rules.