[wiki] [sites] [quark][patch][digestauth] add stale nonce handling || José Miguel Sánchez García

From: <git_AT_suckless.org>
Date: Fri, 30 Oct 2020 23:46:53 +0100

commit ff395473a9dc81bdf9fb4988cbbcdb10826c1493
Author: José Miguel Sánchez García <soy.jmi2k_AT_gmail.com>
Date: Fri Oct 30 22:45:34 2020 +0000

    [quark][patch][digestauth] add stale nonce handling

diff --git a/tools.suckless.org/quark/patches/digestauth/quark-digestauth-20200916-5d0221d.diff b/tools.suckless.org/quark/patches/digestauth/quark-digestauth-20200916-5d0221d.diff
index ed3eeeb8..27d82676 100644
--- a/tools.suckless.org/quark/patches/digestauth/quark-digestauth-20200916-5d0221d.diff
+++ b/tools.suckless.org/quark/patches/digestauth/quark-digestauth-20200916-5d0221d.diff
_AT_@ -1,4 +1,4 @@
-From b62f5dbb095f337f62ed3379948da4283175d7fb Mon Sep 17 00:00:00 2001
+From e0efcece3647fad31ca2750aaf59dd39dd192496 Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20S=C3=A1nchez=20Garc=C3=ADa?=
  <soy.jmi2k_AT_gmail.com>
 Date: Thu, 29 Oct 2020 10:05:27 +0000
_AT_@ -8,14 +8,14 @@ This follows RFC 7616, but only MD5 algorithm and auth qop is supported.
 ---
  Makefile | 3 +-
  config.def.h | 2 +-
- http.c | 289 +++++++++++++++++++++++++++++++++++++++++++++++++--
- http.h | 27 ++++-
+ http.c | 291 +++++++++++++++++++++++++++++++++++++++++++++++++--
+ http.h | 28 ++++-
  main.c | 77 ++++++++++++--
  md5.c | 148 ++++++++++++++++++++++++++
  md5.h | 18 ++++
  quark.1 | 26 +++++
  util.h | 14 +++
- 9 files changed, 581 insertions(+), 23 deletions(-)
+ 9 files changed, 584 insertions(+), 23 deletions(-)
  create mode 100644 md5.c
  create mode 100644 md5.h
 
_AT_@ -53,7 +53,7 @@ index 56f62aa..a322e7a 100644
  /* mime-types */
  static const struct {
 diff --git a/http.c b/http.c
-index f1e15a4..4ceef04 100644
+index f1e15a4..1862dc4 100644
 --- a/http.c
 +++ b/http.c
 _AT_@ -17,13 +17,16 @@
_AT_@ -301,7 +301,7 @@ index f1e15a4..4ceef04 100644
          char *p, *mime;
          const char *targethost;
  
-_AT_@ -787,14 +969,62 @@ http_prepare_response(const struct request *req, struct response *res,
+_AT_@ -787,14 +969,63 @@ http_prepare_response(const struct request *req, struct response *res,
                  }
          }
  
_AT_@ -352,8 +352,9 @@ index f1e15a4..4ceef04 100644
 + auth.cnonce, auth.qop))) {
 + goto err;
 + }
-+ printf("client nonce: %s
", auth.nonce);
-+ printf("server nonce: %s
", nonce);
++ if (strcmp(auth.nonce, nonce)) {
++ req->stale = 1;
++ }
 + if (strncmp(response, auth.response, sizeof(response))) {
 + s = S_UNAUTHORIZED;
 + goto err;
_AT_@ -367,7 +368,7 @@ index f1e15a4..4ceef04 100644
          if (esnprintf(res->field[RES_ACCEPT_RANGES],
                        sizeof(res->field[RES_ACCEPT_RANGES]),
                        "%s", "bytes")) {
-_AT_@ -832,17 +1062,22 @@ http_prepare_response(const struct request *req, struct response *res,
+_AT_@ -832,17 +1063,22 @@ http_prepare_response(const struct request *req, struct response *res,
  
          return;
  err:
_AT_@ -393,7 +394,7 @@ index f1e15a4..4ceef04 100644
          memset(res, 0, sizeof(*res));
  
          res->type = RESTYPE_ERROR;
-_AT_@ -861,4 +1096,38 @@ http_prepare_error_response(const struct request *req,
+_AT_@ -861,4 +1097,39 @@ http_prepare_error_response(const struct request *req,
                          res->status = S_INTERNAL_SERVER_ERROR;
                  }
          }
_AT_@ -412,9 +413,10 @@ index f1e15a4..4ceef04 100644
 + "realm=\"%s\", "
 + "qop=\"auth\", "
 + "algorithm=MD5, "
-+ "stale=false, "
++ "stale=%s, "
 + "nonce=\"%s\"",
 + req->realm->name,
++ req->stale ? "true" : "false",
 + nonce)) {
 + res->status = S_INTERNAL_SERVER_ERROR;
 + } else {
_AT_@ -433,7 +435,7 @@ index f1e15a4..4ceef04 100644
 + }
  }
 diff --git a/http.h b/http.h
-index bfaa807..12de2eb 100644
+index bfaa807..215bb8f 100644
 --- a/http.h
 +++ b/http.h
 _AT_@ -12,6 +12,7 @@ enum req_field {
_AT_@ -444,15 +446,16 @@ index bfaa807..12de2eb 100644
          NUM_REQ_FIELDS,
  };
  
-_AT_@ -28,6 +29,7 @@ extern const char *req_method_str[];
+_AT_@ -28,6 +29,8 @@ extern const char *req_method_str[];
  struct request {
          enum req_method method;
          char uri[PATH_MAX];
 + struct realm *realm;
++ int stale;
          char field[NUM_REQ_FIELDS][FIELD_MAX];
  };
  
-_AT_@ -37,6 +39,7 @@ enum status {
+_AT_@ -37,6 +40,7 @@ enum status {
          S_MOVED_PERMANENTLY = 301,
          S_NOT_MODIFIED = 304,
          S_BAD_REQUEST = 400,
_AT_@ -460,7 +463,7 @@ index bfaa807..12de2eb 100644
          S_FORBIDDEN = 403,
          S_NOT_FOUND = 404,
          S_METHOD_NOT_ALLOWED = 405,
-_AT_@ -57,6 +60,7 @@ enum res_field {
+_AT_@ -57,6 +61,7 @@ enum res_field {
          RES_CONTENT_LENGTH,
          RES_CONTENT_RANGE,
          RES_CONTENT_TYPE,
_AT_@ -468,7 +471,7 @@ index bfaa807..12de2eb 100644
          NUM_RES_FIELDS,
  };
  
-_AT_@ -72,6 +76,7 @@ enum res_type {
+_AT_@ -72,6 +77,7 @@ enum res_type {
  struct response {
          enum res_type type;
          enum status status;
_AT_@ -476,7 +479,7 @@ index bfaa807..12de2eb 100644
          char field[NUM_RES_FIELDS][FIELD_MAX];
          char uri[PATH_MAX];
          char path[PATH_MAX];
-_AT_@ -83,6 +88,7 @@ struct response {
+_AT_@ -83,6 +89,7 @@ struct response {
  
  enum conn_state {
          C_VACANT,
_AT_@ -484,7 +487,7 @@ index bfaa807..12de2eb 100644
          C_RECV_HEADER,
          C_SEND_HEADER,
          C_SEND_BODY,
-_AT_@ -91,6 +97,7 @@ enum conn_state {
+_AT_@ -91,6 +98,7 @@ enum conn_state {
  
  struct connection {
          enum conn_state state;
_AT_@ -492,7 +495,7 @@ index bfaa807..12de2eb 100644
          int fd;
          struct sockaddr_storage ia;
          struct request req;
-_AT_@ -99,13 +106,25 @@ struct connection {
+_AT_@ -99,13 +107,25 @@ struct connection {
          size_t progress;
  };
  
Received on Fri Oct 30 2020 - 23:46:53 CET

This archive was generated by hypermail 2.3.0 : Fri Oct 30 2020 - 23:48:43 CET