2019-05-01 Fred Gleason <fredg@paravelsystems.com>

* Fixed bugs in rd_import(7) that caused corruption of multi-byte
	UTF-8 characters.
This commit is contained in:
Fred Gleason 2019-05-01 12:35:28 -04:00
parent 40b98bec92
commit e1db731e0c
3 changed files with 9 additions and 28 deletions

View File

@ -18626,3 +18626,6 @@
2019-04-30 Fred Gleason <fredg@paravelsystems.com>
* Added an appendix containing the 'GNU Free Documentation License'
to the Operations Guide.
2019-05-01 Fred Gleason <fredg@paravelsystems.com>
* Fixed bugs in rd_import(7) that caused corruption of multi-byte
UTF-8 characters.

View File

@ -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);

View File

@ -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'))