Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes and improvements to curl module
- Fix invalid check of uri and postdata parameters - Fix fixup functions - Refactor curl function to remove dependance on pv/fixup structures - Export curl_connect through C API - Fix buffer overflow in curl write function
- Loading branch information
Hugh Waite
committed
Dec 9, 2015
1 parent
b56fae6
commit 9fd99ef
Showing
5 changed files
with
283 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "functions.h" | ||
#include "curl_api.h" | ||
int bind_curl_api(curl_api_t *api) | ||
{ | ||
if (!api) { | ||
ERR("Invalid parameter value\n"); | ||
return -1; | ||
} | ||
api->curl_connect = curl_con_query_url; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef _CURL_CPI_H_ | ||
#define _CURL_API_H_ | ||
|
||
#include "../../sr_module.h" | ||
#include "functions.h" | ||
|
||
typedef int (*curlapi_curlconnect_f)(struct sip_msg *msg, const str *connection, const str* _url, str* _result, const char *contenttype, const str* _post); | ||
|
||
typedef struct curl_api { | ||
curlapi_curlconnect_f curl_connect; | ||
} curl_api_t; | ||
|
||
typedef int (*bind_curl_api_f)(curl_api_t *api); | ||
int bind_curl_api(curl_api_t *api); | ||
|
||
/** | ||
* @brief Load the CURL API | ||
*/ | ||
static inline int curl_load_api(curl_api_t *api) | ||
{ | ||
bind_curl_api_f bindcurl; | ||
|
||
bindcurl = (bind_curl_api_f)find_export("bind_curl", 0, 0); | ||
if(bindcurl == 0) { | ||
LM_ERR("cannot find bind_curl\n"); | ||
return -1; | ||
} | ||
if (bindcurl(api) < 0) | ||
{ | ||
LM_ERR("cannot bind curl api\n"); | ||
return -1; | ||
} | ||
return 0; | ||
} | ||
|
||
#endif |
Oops, something went wrong.