diff --git a/xorriso/opts_p_z.c b/xorriso/opts_p_z.c index 8f31b12d..67a12c8a 100644 --- a/xorriso/opts_p_z.c +++ b/xorriso/opts_p_z.c @@ -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"); diff --git a/xorriso/text_io.c b/xorriso/text_io.c index b519553b..229c9398 100644 --- a/xorriso/text_io.c +++ b/xorriso/text_io.c @@ -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); +} + diff --git a/xorriso/text_io.h b/xorriso/text_io.h index e4a7d820..a09d48ee 100644 --- a/xorriso/text_io.h +++ b/xorriso/text_io.h @@ -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 diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 40cb0d3f..9bef3a63 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2019.07.22.181418" +#define Xorriso_timestamP "2019.07.24.073750"