2018-11-07 Fred Gleason <fredg@paravelsystems.com>

* Modified rd_deleteaudio(7) in the rivwebcapi to process UTF-8.
This commit is contained in:
Fred Gleason 2018-11-07 14:28:04 -05:00
parent e05d707ed5
commit 0d271e168c
2 changed files with 59 additions and 3 deletions

View File

@ -17988,3 +17988,5 @@
* Fixed buffer overflow bugs in the rd_export(7) rivcwebapi call.
* Fixed buffer overflow bugs in the rd_listservices(7) rivcwebapi call.
* Fixed buffer overflow bugs in the rd_trimaudio(7) rivcwebapi call.
2018-11-07 Fred Gleason <fredg@paravelsystems.com>
* Modified rd_deleteaudio(7) in the rivwebcapi to process UTF-8.

View File

@ -82,7 +82,9 @@ int RD_DeleteAudio( const char hostname[],
char errbuf[CURL_ERROR_SIZE];
CURLcode res;
char user_agent_string[255];
char cart_buffer[7];
struct curl_httppost *first=NULL;
struct curl_httppost *last=NULL;
if((curl=curl_easy_init())==NULL) {
curl_easy_cleanup(curl);
@ -99,13 +101,63 @@ int RD_DeleteAudio( const char hostname[],
__DeleteAudioElementEnd);
XML_SetCharacterDataHandler(parser,__DeleteAudioElementData);
snprintf(url,1500,"http://%s/rd-bin/rdxport.cgi",hostname);
curl_formadd(&first,
&last,
CURLFORM_PTRNAME,
"COMMAND",
CURLFORM_COPYCONTENTS,
"3",
CURLFORM_END);
curl_formadd(&first,
&last,
CURLFORM_PTRNAME,
"LOGIN_NAME",
CURLFORM_COPYCONTENTS,
username,
CURLFORM_END);
curl_formadd(&first,
&last,
CURLFORM_PTRNAME,
"PASSWORD",
CURLFORM_COPYCONTENTS,
passwd,
CURLFORM_END);
curl_formadd(&first,
&last,
CURLFORM_PTRNAME,
"TICKET",
CURLFORM_COPYCONTENTS,
ticket,
CURLFORM_END);
snprintf(cart_buffer,7,"%u",cartnumber);
curl_formadd(&first,
&last,
CURLFORM_PTRNAME,
"CART_NUMBER",
CURLFORM_COPYCONTENTS,
cart_buffer,
CURLFORM_END);
snprintf(cart_buffer,7,"%u",cutnumber);
curl_formadd(&first,
&last,
CURLFORM_PTRNAME,
"CUT_NUMBER",
CURLFORM_COPYCONTENTS,
cart_buffer,
CURLFORM_END);
/*
snprintf(post,1500,"COMMAND=3&LOGIN_NAME=%s&PASSWORD=%s&TICKET=%s&CART_NUMBER=%u&CUT_NUMBER=%u",
curl_easy_escape(curl,username,0),
curl_easy_escape(curl,passwd,0),
curl_easy_escape(curl,ticket,0),
cartnumber,
cutnumber);
*/
// Check if User Agent Present otherwise set to default
if (strlen(user_agent)> 0){
curl_easy_setopt(curl, CURLOPT_USERAGENT,user_agent);
@ -121,7 +173,7 @@ int RD_DeleteAudio( const char hostname[],
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,__DeleteAudioCallback);
curl_easy_setopt(curl,CURLOPT_URL,url);
curl_easy_setopt(curl,CURLOPT_POST,1);
curl_easy_setopt(curl,CURLOPT_POSTFIELDS,post);
curl_easy_setopt(curl,CURLOPT_HTTPPOST,first);
curl_easy_setopt(curl,CURLOPT_NOPROGRESS,1);
curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errbuf);
// curl_easy_setopt(curl,CURLOPT_VERBOSE,1);
@ -136,12 +188,14 @@ int RD_DeleteAudio( const char hostname[],
else
fprintf(stderr, "%s\n", curl_easy_strerror(res));
#endif
curl_formfree(first);
curl_easy_cleanup(curl);
return -1;
}
/* The response OK - so figure out if we got what we wanted.. */
curl_easy_getinfo(curl,CURLINFO_RESPONSE_CODE,&response_code);
curl_formfree(first);
curl_easy_cleanup(curl);
if (response_code > 199 && response_code < 300) { //Success