Module: kamailio Branch: master Commit: 796bcc038d7885e01dbad34abc68bf612062c533 URL: https://github.com/kamailio/kamailio/commit/796bcc038d7885e01dbad34abc68bf61...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2024-07-24T10:37:21+02:00
jsonrpcc: free allocated pkg buffer on error
---
Modified: src/modules/jsonrpcc/netstring.c
---
Diff: https://github.com/kamailio/kamailio/commit/796bcc038d7885e01dbad34abc68bf61... Patch: https://github.com/kamailio/kamailio/commit/796bcc038d7885e01dbad34abc68bf61...
---
diff --git a/src/modules/jsonrpcc/netstring.c b/src/modules/jsonrpcc/netstring.c index bf7294ceb41..be7a5de8108 100644 --- a/src/modules/jsonrpcc/netstring.c +++ b/src/modules/jsonrpcc/netstring.c @@ -77,12 +77,16 @@ int netstring_read_fd(int fd, char **netstring) bytes = recv(fd, buffer2, read_len, 0);
/* Make sure we got the whole netstring */ - if(read_len > bytes) + if(read_len > bytes) { + pkg_free(buffer2); return NETSTRING_ERROR_TOO_SHORT; + }
/* Test for the trailing comma */ - if(buffer2[read_len - 1] != ',') + if(buffer2[read_len - 1] != ',') { + pkg_free(buffer2); return NETSTRING_ERROR_NO_COMMA; + }
buffer2[read_len - 1] = '\0';