Module: kamailio
Branch: master
Commit: 7eb96925c4bb4664cce589050dff3e1c8b98b6f0
URL:
https://github.com/kamailio/kamailio/commit/7eb96925c4bb4664cce589050dff3e1…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-12-11T15:51:01+01:00
siptrace: check sscan() return value
---
Modified: src/modules/siptrace/siptrace_send.c
---
Diff:
https://github.com/kamailio/kamailio/commit/7eb96925c4bb4664cce589050dff3e1…
Patch:
https://github.com/kamailio/kamailio/commit/7eb96925c4bb4664cce589050dff3e1…
---
diff --git a/src/modules/siptrace/siptrace_send.c b/src/modules/siptrace/siptrace_send.c
index bac4ad04779..d8a5f974bb3 100644
--- a/src/modules/siptrace/siptrace_send.c
+++ b/src/modules/siptrace/siptrace_send.c
@@ -158,7 +158,8 @@ int sip_trace_xheaders_read(struct _siptrace_data *sto)
char *searchend = NULL;
char *eoh = NULL;
char *xheaders = NULL;
- long long unsigned int tv_sec, tv_usec;
+ long long unsigned int tv_sec = 0, tv_usec = 0;
+ int rv = 0;
if(trace_xheaders_read == 0) {
return 0;
@@ -202,16 +203,17 @@ int sip_trace_xheaders_read(struct _siptrace_data *sto)
}
// Parse the x-headers: scanf()
- if(sscanf(xheaders,
- "\r\n"
- "X-Siptrace-Fromip: %50s\r\n"
- "X-Siptrace-Toip: %50s\r\n"
- "X-Siptrace-Time: %llu %llu\r\n"
- "X-Siptrace-Method: %50s\r\n"
- "X-Siptrace-Dir: %3s",
- sto->fromip.s, sto->toip.s, &tv_sec, &tv_usec, sto->method.s,
- sto->dir)
- == EOF) {
+ rv = sscanf(xheaders,
+ "\r\n"
+ "X-Siptrace-Fromip: %50s\r\n"
+ "X-Siptrace-Toip: %50s\r\n"
+ "X-Siptrace-Time: %llu %llu\r\n"
+ "X-Siptrace-Method: %50s\r\n"
+ "X-Siptrace-Dir: %3s",
+ sto->fromip.s, sto->toip.s, &tv_sec, &tv_usec, sto->method.s,
+ sto->dir);
+
+ if(rv == EOF || rv < 6) {
LM_ERR("malformed x-headers\n");
goto erroraftermalloc;
}