Module: kamailio
Branch: master
Commit: bd9f566a7eb0022ff4902883189d8123c0d02eca
URL: 
https://github.com/kamailio/kamailio/commit/bd9f566a7eb0022ff4902883189d8123c0d02eca

Author: frederic <[email protected]>
Committer: Henning Westerholt <[email protected]>
Date: 2026-06-10T10:56:01+02:00

core: enhanced RFC 1123 date parsing, day number may be encoded with 1 or 2 
characters according to RFC 1123

---

Modified: src/core/parser/parse_date.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/bd9f566a7eb0022ff4902883189d8123c0d02eca.diff
Patch: 
https://github.com/kamailio/kamailio/commit/bd9f566a7eb0022ff4902883189d8123c0d02eca.patch

---

diff --git a/src/core/parser/parse_date.c b/src/core/parser/parse_date.c
index a273a84649a..4ab9200b235 100644
--- a/src/core/parser/parse_date.c
+++ b/src/core/parser/parse_date.c
@@ -49,6 +49,15 @@ inline static int char2int(char *p, int *t)
        return 0;
 }
 
+inline static int onechar2int(char *p, int *t)
+{
+       if(*p < '0' || *p > '9')
+               return -1;
+       *t = *p - '0';
+
+       return 0;
+}
+
 /*! \brief
  * Converts a RFC 1123 formatted date string to stuct tm
  */
@@ -96,10 +105,15 @@ static int rfc1123totm(char *stime, struct tm *ttm)
        if(*(ptime++) != ' ')
                return -3;
 
-
-       if(char2int(ptime, &ttm->tm_mday) || ttm->tm_mday > 31)
-               return -4;
-       ptime += 2;
+       if(*(ptime + 1) == ' ') {
+               if(onechar2int(ptime, &ttm->tm_mday) || ttm->tm_mday > 9)
+                       return -4;
+               ptime += 1;
+       } else {
+               if(char2int(ptime, &ttm->tm_mday) || ttm->tm_mday > 31)
+                       return -4;
+               ptime += 2;
+       }
 
        if(*(ptime++) != ' ')
                return -5;

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to