From e1db731e0cf921eaed3ebe1be4a2c4a563fc5b2a Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Wed, 1 May 2019 12:35:28 -0400 Subject: [PATCH] 2019-05-01 Fred Gleason * Fixed bugs in rd_import(7) that caused corruption of multi-byte UTF-8 characters. --- ChangeLog | 3 +++ apis/rivwebcapi/rivwebcapi/rd_import.c | 29 ++----------------------- apis/rivwebcapi/tests/importcart_test.c | 5 ++++- 3 files changed, 9 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index bd3eefbf..cd02582d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18626,3 +18626,6 @@ 2019-04-30 Fred Gleason * Added an appendix containing the 'GNU Free Documentation License' to the Operations Guide. +2019-05-01 Fred Gleason + * Fixed bugs in rd_import(7) that caused corruption of multi-byte + UTF-8 characters. diff --git a/apis/rivwebcapi/rivwebcapi/rd_import.c b/apis/rivwebcapi/rivwebcapi/rd_import.c index 7715357f..20f2c36c 100644 --- a/apis/rivwebcapi/rivwebcapi/rd_import.c +++ b/apis/rivwebcapi/rivwebcapi/rd_import.c @@ -111,8 +111,6 @@ int RD_ImportCart(struct rd_cartimport *cartimport[], long response_code; struct curl_httppost *first=NULL; struct curl_httppost *last=NULL; - char *arrayptr; - char checked_fname[BUFSIZ]; int i; char cart_buffer[50]; char cut_buffer[50]; @@ -121,35 +119,12 @@ int RD_ImportCart(struct rd_cartimport *cartimport[], char autotrim_buffer[50]; char use_metadata_buffer[50]; char create_flag[50]; - char checked_group_name[50]; long userlen = strlen(username); long passwdlen = strlen(passwd); char errbuf[CURL_ERROR_SIZE]; CURLcode res; char user_agent_string[255]; - /* Check File name */ - memset(checked_fname,'\0',sizeof(checked_fname)); - arrayptr=&checked_fname[0]; - - for (i = 0 ; i < strlen(filename) ; i++) { - if (filename[i]>32) { - strncpy(arrayptr,&filename[i],1); - arrayptr++; - } - } - - /* Check Group Name */ - memset(checked_group_name,'\0',sizeof(checked_group_name)); - arrayptr=&checked_group_name[0]; - - for (i = 0 ; i < strlen(group) ; i++) { - if (group[i]>32) { - strncpy(arrayptr,&group[i],1); - arrayptr++; - } - } - if((curl=curl_easy_init())==NULL) { curl_easy_cleanup(curl); return -1; @@ -260,7 +235,7 @@ int RD_ImportCart(struct rd_cartimport *cartimport[], CURLFORM_PTRNAME, "GROUP_NAME", CURLFORM_COPYCONTENTS, - checked_group_name, + group, CURLFORM_END); curl_formadd(&first, @@ -276,7 +251,7 @@ int RD_ImportCart(struct rd_cartimport *cartimport[], CURLFORM_PTRNAME, "FILENAME", CURLFORM_FILE, - checked_fname, + filename, CURLFORM_END); diff --git a/apis/rivwebcapi/tests/importcart_test.c b/apis/rivwebcapi/tests/importcart_test.c index 7577a7a4..d7dd3702 100644 --- a/apis/rivwebcapi/tests/importcart_test.c +++ b/apis/rivwebcapi/tests/importcart_test.c @@ -96,9 +96,12 @@ int main(int argc,char *argv[]) printf("Please enter the File Name that you want to Import ==> "); if (fgets(filename,sizeof(filename),stdin) != NULL) { + if((0xFF&filename[strlen(filename)-1])<32) { + filename[strlen(filename)-1]=0; + } } - printf("Do you want to Create Cart If Doesn't Exist - (Yes or No) ==> "); + printf("Do you want to Create Cart If Doesn't Exist - (Y/N) ==> "); if (fgets(buf,sizeof(buf),stdin) != NULL) { if (( buf[0] != '\n') && (buf[0] =='Y'))