Bug fix: Very large ACL texts led to SIGSEGV with -setfacl* commands. Thanks Eliska Svobodova.

This commit is contained in:
Thomas Schmitt 2019-07-24 09:38:28 +02:00
parent 397551f9d4
commit 321a0476fa
4 changed files with 36 additions and 4 deletions

View File

@ -831,12 +831,13 @@ int Xorriso_option_session_log(struct XorrisO *xorriso, char *path, int flag)
int Xorriso_option_setfacl_listi(struct XorrisO *xorriso, char *path, int flag)
{
int ret, eaten, line_size;
size_t buf_size= 0, buf_add= 64 * 1024, l, linecount= 0;
size_t buf_size= 0, buf_add, l, linecount= 0, diff_buf_wpt;
char *line= NULL, *buf= NULL, *wpt, *new_buf, limit_text[80];
char *file_path= NULL, *uid= NULL, *gid= NULL;
FILE *fp= NULL;
line_size= SfileadrL * 4;
buf_add= line_size * 4;
Xorriso_alloc_meM(line, char, line_size);
Xorriso_alloc_meM(file_path, char, SfileadrL);
Xorriso_alloc_meM(uid, char, 161);
@ -923,11 +924,13 @@ int Xorriso_option_setfacl_listi(struct XorrisO *xorriso, char *path, int flag)
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
diff_buf_wpt= wpt - buf;
buf_size+= buf_add;
new_buf= realloc(buf, buf_size);
if(new_buf == NULL)
goto out_of_mem;
buf= new_buf;
wpt= buf + diff_buf_wpt;
}
memcpy(wpt, line, l);
*(wpt + l)= '\n';
@ -989,9 +992,11 @@ int Xorriso_option_setfacli(struct XorrisO *xorriso, char *acl_text,
ret= Xorriso_normalize_acl_text(xorriso, acl_text,
&access_acl_text, &default_acl_text, 0);
if(access_acl_text != NULL && default_acl_text != NULL) {
sprintf(xorriso->info_text, "Access-ACL :\n%s", access_acl_text);
strcpy(xorriso->info_text, "Access-ACL :\n");
Xorriso_set_info_text(xorriso, access_acl_text, 2000, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
sprintf(xorriso->info_text, "Default-ACL :\n%s", default_acl_text);
strcpy(xorriso->info_text, "Default-ACL :\n");
Xorriso_set_info_text(xorriso, default_acl_text, 2000, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
} else if(access_acl_text == NULL && default_acl_text == NULL) {
sprintf(xorriso->info_text, "Will delete Access-ACL and Default-ACL");

View File

@ -4707,3 +4707,27 @@ char *Xorriso_esc_filepath(struct XorrisO *xorriso,
return(out_text);
}
/* @param flag bit=add to existing info_text
*/
int Xorriso_set_info_text(struct XorrisO *xorriso, char *text,
size_t trunc_len, int flag)
{
size_t offst= 0, maxl;
maxl= sizeof(xorriso->info_text) - 1;
if(flag & 1)
offst= strlen(xorriso->info_text);
if(offst >= maxl)
return(0);
maxl-= offst;
if(maxl > trunc_len)
maxl= trunc_len;
strncpy(xorriso->info_text + offst, text, maxl + 1);
if(strlen(text) > maxl) {
strcpy(xorriso->info_text + offst + maxl - 12, "#[truncated]");
return(2);
}
return(1);
}

View File

@ -105,6 +105,9 @@ int Xorriso_named_pipe_loop(struct XorrisO *xorriso,
char *Xorriso_esc_filepath(struct XorrisO *xorriso,
char *in_text, char *out_text, int flag);
int Xorriso_set_info_text(struct XorrisO *xorriso, char *text,
size_t trunc_len, int flag);
#ifdef Xorriso_with_editlinE
int Xorriso__shutdown_editline(int flag);
#endif

View File

@ -1 +1 @@
#define Xorriso_timestamP "2019.07.22.181418"
#define Xorriso_timestamP "2019.07.24.073750"