[sr-dev] [kamailio/kamailio] runtime error: null pointer passed as argument 2, which is declared to never be null (Issue #2913)

sergey-safarov notifications at github.com
Sat Oct 30 23:21:03 CEST 2021


### Description

I have compiled Kamailio with google ASAN module and faced issue where the string PV with NULL value cannot be copied.
Using GDB I found this function call triggers error when Google ASAN is used, `value->s.s = NULL`, `value->s.len = 0`
```
memcpy(var->v.value.s.s, value->s.s, value->s.len);
```
[Link](https://github.com/kamailio/kamailio/blob/caccb13e29ee12166c8101efa0d5ab2745876413/src/modules/pv/pv_svar.c#L137)
This happens only when ASAN is used.
Without ASAN same function call with the same values does not trigger an error.

In my test case this function called from [`lost/functions.c:1285`](https://github.com/kamailio/kamailio/blob/caccb13e29ee12166c8101efa0d5ab2745876413/src/modules/lost/functions.c#L1285)

To compile with asan used extra flags
```
-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment 
```

### Troubleshooting
#### Log Messages
```
 0(913407) INFO: {1 1 INVITE 1-455779 at 172.21.0.84} lost [functions.c:891]: lost_function(): ### LOST urn	[urn:sip:911 at 3.236.25.254:5060]
 0(913407) INFO: {1 1 INVITE 1-455779 at 172.21.0.84} lost [functions.c:983]: lost_function(): ### LOST loc	[<112233445566 at jim.com>]
 0(913407) ERROR: {1 1 INVITE 1-455779 at 172.21.0.84} lost [utilities.c:336]: lost_get_content(): could not get XML node content
pv_svar.c:137:3: runtime error: null pointer passed as argument 2, which is declared to never be null
```
### Additional Information

  * **Kamailio Version** - output of `kamailio -v`

current master, test 375f86b69e11cf835ae919873d3cd56f32d589c8

* **Operating System**:

Centos 8

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2913
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20211030/fb866597/attachment.htm>


More information about the sr-dev mailing list