diff --git a/src/algebra.cc b/src/algebra.cc index a4ae3656..9e697a48 100644 --- a/src/algebra.cc +++ b/src/algebra.cc @@ -259,11 +259,11 @@ int compare(const char *expr) int check_if_match(struct text_object *obj) { - std::unique_ptr expression(new char[max_user_text]); + std::unique_ptr expression(new char[max_user_text.get(*state)]); int val; int result = 1; - generate_text_internal(expression.get(), max_user_text, *obj->sub); + generate_text_internal(expression.get(), max_user_text.get(*state), *obj->sub); DBGP("parsed arg into '%s'", expression.get()); val = compare(expression.get()); diff --git a/src/ccurl_thread.cc b/src/ccurl_thread.cc index 3817e04f..8c325335 100644 --- a/src/ccurl_thread.cc +++ b/src/ccurl_thread.cc @@ -185,7 +185,7 @@ void ccurl_free_info(void) /* straight copy, used by $curl */ static void ccurl_parse_data(char *result, const char *data) { - if(result) strncpy(result, data, max_user_text); + if(result) strncpy(result, data, max_user_text.get(*state)); } /* prints result data to text buffer, used by $curl */ @@ -193,8 +193,8 @@ void ccurl_process_info(char *p, int p_max_size, char *uri, int interval) { ccurl_location_ptr curloc = ccurl_find_location(ccurl_locations, uri); if (!curloc->p_timed_thread) { - curloc->result = (char*)malloc(max_user_text); - memset(curloc->result, 0, max_user_text); + curloc->result = (char*)malloc(max_user_text.get(*state)); + memset(curloc->result, 0, max_user_text.get(*state)); curloc->process_function = std::bind(ccurl_parse_data, std::placeholders::_1, std::placeholders::_2); ccurl_init_thread(curloc, interval); diff --git a/src/combine.cc b/src/combine.cc index 65189f41..2615c1db 100644 --- a/src/combine.cc +++ b/src/combine.cc @@ -98,8 +98,8 @@ void print_combine(struct text_object *obj, char *p, int p_max_size) struct combine_data *cd = (struct combine_data *)obj->data.opaque; std::vector> buf; buf.resize(2); - buf[0].resize(max_user_text); - buf[1].resize(max_user_text); + buf[0].resize(max_user_text.get(*state)); + buf[1].resize(max_user_text.get(*state)); int i, j; long longest=0; int nextstart; @@ -121,7 +121,7 @@ void print_combine(struct text_object *obj, char *p, int p_max_size) ll_rows[i] = (struct llrows*)malloc(sizeof(struct llrows)); current[i] = ll_rows[i]; for(j=0; jsub; - generate_text_internal(&(buf[i][0]), max_user_text, *objsub); + generate_text_internal(&(buf[i][0]), max_user_text.get(*state), *objsub); for(j=0; buf[i][j] != 0; j++) { if(buf[i][j] == '\t') buf[i][j] = ' '; if(buf[i][j] == '\n') buf[i][j] = 0; //the vars inside combine may not have a \n at the end diff --git a/src/common.cc b/src/common.cc index c4e96c75..ebdb38a1 100644 --- a/src/common.cc +++ b/src/common.cc @@ -659,10 +659,10 @@ void print_evaluate(struct text_object *obj, char *p, int p_max_size) int if_empty_iftest(struct text_object *obj) { - std::vector buf(max_user_text); + std::vector buf(max_user_text.get(*state)); int result = 1; - generate_text_internal(&(buf[0]), max_user_text, *obj->sub); + generate_text_internal(&(buf[0]), max_user_text.get(*state), *obj->sub); if (strlen(&(buf[0])) != 0) { result = 0; @@ -790,13 +790,13 @@ void print_battery_short(struct text_object *obj, char *p, int p_max_size) void print_blink(struct text_object *obj, char *p, int p_max_size) { //blinking like this can look a bit ugly if the chars in the font don't have the same width - std::vector buf(max_user_text); + std::vector buf(max_user_text.get(*state)); static int visible = 1; static int last_len = 0; int i; if (visible) { - generate_text_internal(&(buf[0]), max_user_text, *obj->sub); + generate_text_internal(&(buf[0]), max_user_text.get(*state), *obj->sub); last_len = strlen(&(buf[0])); } else { for (i = 0; i < last_len; i++) @@ -809,12 +809,12 @@ void print_blink(struct text_object *obj, char *p, int p_max_size) void print_include(struct text_object *obj, char *p, int p_max_size) { - std::vector buf(max_user_text); + std::vector buf(max_user_text.get(*state)); if (!obj->sub) return; - generate_text_internal(&(buf[0]), max_user_text, *obj->sub); + generate_text_internal(&(buf[0]), max_user_text.get(*state), *obj->sub); snprintf(p, p_max_size, "%s", &(buf[0])); } @@ -836,17 +836,17 @@ void free_stock(struct text_object *obj) void print_to_bytes(struct text_object *obj, char *p, int p_max_size) { - std::vector buf(max_user_text); + std::vector buf(max_user_text.get(*state)); long long bytes; char unit[16]; // 16 because we can also have long names (like mega-bytes) - generate_text_internal(&(buf[0]), max_user_text, *obj->sub); + generate_text_internal(&(buf[0]), max_user_text.get(*state), *obj->sub); if(sscanf(&(buf[0]), "%lli%s", &bytes, unit) == 2 && strlen(unit) < 16){ - if(strncasecmp("b", unit, 1) == 0) snprintf(&(buf[0]), max_user_text, "%lli", bytes); - else if(strncasecmp("k", unit, 1) == 0) snprintf(&(buf[0]), max_user_text, "%lli", bytes * 1024); - else if(strncasecmp("m", unit, 1) == 0) snprintf(&(buf[0]), max_user_text, "%lli", bytes * 1024 * 1024); - else if(strncasecmp("g", unit, 1) == 0) snprintf(&(buf[0]), max_user_text, "%lli", bytes * 1024 * 1024 * 1024); - else if(strncasecmp("t", unit, 1) == 0) snprintf(&(buf[0]), max_user_text, "%lli", bytes * 1024 * 1024 * 1024 * 1024); + if(strncasecmp("b", unit, 1) == 0) snprintf(&(buf[0]), max_user_text.get(*state), "%lli", bytes); + else if(strncasecmp("k", unit, 1) == 0) snprintf(&(buf[0]), max_user_text.get(*state), "%lli", bytes * 1024); + else if(strncasecmp("m", unit, 1) == 0) snprintf(&(buf[0]), max_user_text.get(*state), "%lli", bytes * 1024 * 1024); + else if(strncasecmp("g", unit, 1) == 0) snprintf(&(buf[0]), max_user_text.get(*state), "%lli", bytes * 1024 * 1024 * 1024); + else if(strncasecmp("t", unit, 1) == 0) snprintf(&(buf[0]), max_user_text.get(*state), "%lli", bytes * 1024 * 1024 * 1024 * 1024); } snprintf(p, p_max_size, "%s", &(buf[0])); } diff --git a/src/conky.cc b/src/conky.cc index 8812d9c7..72d166ce 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -466,7 +466,8 @@ static conky::simple_config_setting utf8_mode("override_utf8_locale", #endif /* BUILD_X11 */ /* maximum size of config TEXT buffer, i.e. below TEXT line. */ -unsigned int max_user_text; +conky::range_config_setting max_user_text("max_user_text", 47, + std::numeric_limits::max(), MAX_USER_TEXT_DEFAULT, false); /* maximum size of individual text buffers, ie $exec buffer size */ unsigned int text_buffer_size = DEFAULT_TEXT_BUFFER_SIZE; @@ -893,7 +894,7 @@ static void generate_text(void) p = text_buffer; - generate_text_internal(p, max_user_text, global_root_object); + generate_text_internal(p, max_user_text.get(*state), global_root_object); unsigned int mw = max_text_width.get(*state); if(mw > 0) { for(i = 0, j = 0; p[i] != 0; i++) { @@ -2836,13 +2837,6 @@ char load_config_file(const char *f) CONF_ERR; } } - CONF("max_user_text") { - if (value) { - max_user_text = atoi(value); - } else { - CONF_ERR; - } - } CONF("text_buffer_size") { if (value) { text_buffer_size = atoi(value); @@ -2888,7 +2882,7 @@ char load_config_file(const char *f) global_text = (char *) realloc(global_text, l + bl + 1); strcat(global_text, buf); - if (strlen(global_text) > max_user_text) { + if (strlen(global_text) > max_user_text.get(*state)) { break; } } @@ -3093,7 +3087,7 @@ void initialisation(int argc, char **argv) { break; }else if (c == 's') { free_and_zero(global_text); - global_text = strndup(optarg, max_user_text); + global_text = strndup(optarg, max_user_text.get(*state)); convert_escapes(global_text); total_run_times = 1; @@ -3164,7 +3158,7 @@ void initialisation(int argc, char **argv) { #endif /* BUILD_X11 */ case 't': free_and_zero(global_text); - global_text = strndup(optarg, max_user_text); + global_text = strndup(optarg, max_user_text.get(*state)); convert_escapes(global_text); break; @@ -3234,8 +3228,8 @@ void initialisation(int argc, char **argv) { start_update_threading(); - text_buffer = (char*)malloc(max_user_text); - memset(text_buffer, 0, max_user_text); + text_buffer = (char*)malloc(max_user_text.get(*state)); + memset(text_buffer, 0, max_user_text.get(*state)); tmpstring1 = (char*)malloc(text_buffer_size); memset(tmpstring1, 0, text_buffer_size); tmpstring2 = (char*)malloc(text_buffer_size); @@ -3277,7 +3271,6 @@ int main(int argc, char **argv) argc_copy = argc; argv_copy = argv; g_signal_pending = 0; - max_user_text = MAX_USER_TEXT_DEFAULT; clear_net_stats(); /* handle command line parameters that don't change configs */ diff --git a/src/conky.h b/src/conky.h index 87d31171..8dd61bd5 100644 --- a/src/conky.h +++ b/src/conky.h @@ -306,7 +306,7 @@ int percent_print(char *, int, unsigned); void human_readable(long long, char *, int); /* maximum size of config TEXT buffer, i.e. below TEXT line. */ -extern unsigned int max_user_text; +extern conky::range_config_setting max_user_text; /* path to config file */ extern std::string current_config; diff --git a/src/core.cc b/src/core.cc index b301a05a..6e261e26 100644 --- a/src/core.cc +++ b/src/core.cc @@ -1840,7 +1840,7 @@ int extract_variable_text_internal(struct text_object *retval, const char *const char *arg = 0; size_t len = 0; - p = strndup(const_p, max_user_text - 1); + p = strndup(const_p, max_user_text.get(*state) - 1); while (text_contains_templates(p)) { char *tmp; tmp = find_and_replace_templates(p); diff --git a/src/llua.cc b/src/llua.cc index 918ec121..f1cf7cc8 100644 --- a/src/llua.cc +++ b/src/llua.cc @@ -109,7 +109,7 @@ static int llua_conky_parse(lua_State *L) { int n = lua_gettop(L); /* number of arguments */ char *str; - char *buf = (char*)calloc(1, max_user_text); + char *buf = (char*)calloc(1, max_user_text.get(*state)); if (n != 1) { lua_pushstring(L, "incorrect arguments, conky_parse(string) takes exactly 1 argument"); lua_error(L); @@ -119,7 +119,7 @@ static int llua_conky_parse(lua_State *L) lua_error(L); } str = strdup(lua_tostring(L, 1)); - evaluate(str, buf, max_user_text); + evaluate(str, buf, max_user_text.get(*state)); lua_pushstring(L, buf); free(str); free(buf); diff --git a/src/proc.cc b/src/proc.cc index 736a2c0e..ac7c5424 100644 --- a/src/proc.cc +++ b/src/proc.cc @@ -106,9 +106,9 @@ int inlist(struct ll_string* front, char* string) { void print_pid_chroot(struct text_object *obj, char *p, int p_max_size) { char pathbuf[64]; - std::unique_ptr buf(new char[max_user_text]); + std::unique_ptr buf(new char[max_user_text.get(*state)]); - generate_text_internal(buf.get(), max_user_text, *obj->sub); + generate_text_internal(buf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/root", buf.get()); pid_readlink(pathbuf, p, p_max_size); } @@ -118,9 +118,9 @@ void print_pid_cmdline(struct text_object *obj, char *p, int p_max_size) char* buf; int i, bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); if(*(objbuf.get()) != 0) { snprintf(pathbuf, 64, PROCDIR "/%s/cmdline", objbuf.get()); @@ -144,9 +144,9 @@ void print_pid_cwd(struct text_object *obj, char *p, int p_max_size) std::unique_ptr buf(new char[p_max_size]); int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/cwd", objbuf.get()); bytes_read = readlink(pathbuf, buf.get(), p_max_size); if(bytes_read != -1) { @@ -162,10 +162,10 @@ void print_pid_environ(struct text_object *obj, char *p, int p_max_size) int i, total_read; pid_t pid; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); char *buf, *var=strdup(obj->data.s);; - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); if(sscanf(objbuf.get(), "%d %s", &pid, var) == 2) { for(i = 0; var[i] != 0; i++) { var[i] = toupper(var[i]); @@ -195,9 +195,9 @@ void print_pid_environ_list(struct text_object *obj, char *p, int p_max_size) int bytes_read, total_read; int i = 0; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/environ", objbuf.get()); buf = readfile(pathbuf, &total_read, 1); @@ -217,9 +217,9 @@ void print_pid_environ_list(struct text_object *obj, char *p, int p_max_size) void print_pid_exe(struct text_object *obj, char *p, int p_max_size) { char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/exe", objbuf.get()); pid_readlink(pathbuf, p, p_max_size); } @@ -229,9 +229,9 @@ void print_pid_nice(struct text_object *obj, char *p, int p_max_size) { int bytes_read; long int nice_value; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); if(*(obj->data.s) != 0) { snprintf(pathbuf, 64, PROCDIR "/%s/stat", objbuf.get()); @@ -253,9 +253,9 @@ void print_pid_openfiles(struct text_object *obj, char *p, int p_max_size) { int length, totallength = 0; struct ll_string* files_front = NULL; struct ll_string* files_back = NULL; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); dir = opendir(objbuf.get()); if(dir != NULL) { @@ -288,9 +288,9 @@ void print_pid_parent(struct text_object *obj, char *p, int p_max_size) { char *begin, *end, *buf = NULL; int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/status", objbuf.get()); buf = readfile(pathbuf, &bytes_read, 1); @@ -315,9 +315,9 @@ void print_pid_priority(struct text_object *obj, char *p, int p_max_size) { int bytes_read; long int priority; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); if(*(objbuf.get()) != 0) { snprintf(pathbuf, 64, PROCDIR "/%s/stat", objbuf.get()); @@ -338,9 +338,9 @@ void print_pid_state(struct text_object *obj, char *p, int p_max_size) { char *begin, *end, *buf = NULL; int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/status", objbuf.get()); buf = readfile(pathbuf, &bytes_read, 1); @@ -364,9 +364,9 @@ void print_pid_state_short(struct text_object *obj, char *p, int p_max_size) { char *begin, *buf = NULL; int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/status", objbuf.get()); @@ -384,19 +384,19 @@ void print_pid_state_short(struct text_object *obj, char *p, int p_max_size) { void print_pid_stderr(struct text_object *obj, char *p, int p_max_size) { char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/fd/2", objbuf.get()); pid_readlink(pathbuf, p, p_max_size); } void print_pid_stdin(struct text_object *obj, char *p, int p_max_size) { - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); char pathbuf[64]; - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/fd/0", objbuf.get()); pid_readlink(pathbuf, p, p_max_size); @@ -404,9 +404,9 @@ void print_pid_stdin(struct text_object *obj, char *p, int p_max_size) { void print_pid_stdout(struct text_object *obj, char *p, int p_max_size) { char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/fd/1", objbuf.get()); pid_readlink(pathbuf, p, p_max_size); @@ -414,10 +414,10 @@ void print_pid_stdout(struct text_object *obj, char *p, int p_max_size) { void scan_cmdline_to_pid_arg(struct text_object *obj, const char *arg, void* free_at_crash) { unsigned int i; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); /* FIXME */ - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); if(strlen(arg) > 0) { obj->data.s = strdup(arg); @@ -472,9 +472,9 @@ void print_pid_threads(struct text_object *obj, char *p, int p_max_size) { char *begin, *end, *buf = NULL; int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/status", objbuf.get()); buf = readfile(pathbuf, &bytes_read, 1); @@ -499,9 +499,9 @@ void print_pid_thread_list(struct text_object *obj, char *p, int p_max_size) { struct dirent *entry; int totallength = 0; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/task", objbuf.get()); dir = opendir(pathbuf); @@ -524,9 +524,9 @@ void print_pid_time_kernelmode(struct text_object *obj, char *p, int p_max_size) int bytes_read; unsigned long int umtime; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); if(*(objbuf.get()) != 0) { snprintf(pathbuf, 64, PROCDIR "/%s/stat", objbuf.get()); @@ -546,9 +546,9 @@ void print_pid_time_usermode(struct text_object *obj, char *p, int p_max_size) { int bytes_read; unsigned long int kmtime; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); if(*(objbuf.get()) != 0) { snprintf(pathbuf, 64, PROCDIR "/%s/stat", objbuf.get()); @@ -568,9 +568,9 @@ void print_pid_time(struct text_object *obj, char *p, int p_max_size) { int bytes_read; unsigned long int umtime, kmtime; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); if(*(objbuf.get()) != 0) { snprintf(pathbuf, 64, PROCDIR "/%s/stat", objbuf.get()); @@ -591,9 +591,9 @@ void print_pid_uid(struct text_object *obj, char *p, int p_max_size) { char *begin, *end, *buf = NULL; int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/status", objbuf.get()); buf = readfile(pathbuf, &bytes_read, 1); @@ -618,9 +618,9 @@ void print_pid_euid(struct text_object *obj, char *p, int p_max_size) { char *begin, *end, *buf = NULL; int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/status", objbuf.get()); buf = readfile(pathbuf, &bytes_read, 1); @@ -646,9 +646,9 @@ void print_pid_suid(struct text_object *obj, char *p, int p_max_size) { char *begin, *end, *buf = NULL; int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/status", objbuf.get()); buf = readfile(pathbuf, &bytes_read, 1); @@ -675,9 +675,9 @@ void print_pid_fsuid(struct text_object *obj, char *p, int p_max_size) { char *begin, *end, *buf = NULL; int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/status", objbuf.get()); buf = readfile(pathbuf, &bytes_read, 1); @@ -706,9 +706,9 @@ void print_pid_gid(struct text_object *obj, char *p, int p_max_size) { char *begin, *end, *buf = NULL; int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/status", objbuf.get()); buf = readfile(pathbuf, &bytes_read, 1); @@ -733,9 +733,9 @@ void print_pid_egid(struct text_object *obj, char *p, int p_max_size) { char *begin, *end, *buf = NULL; int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/status", objbuf.get()); buf = readfile(pathbuf, &bytes_read, 1); @@ -761,9 +761,9 @@ void print_pid_sgid(struct text_object *obj, char *p, int p_max_size) { char *begin, *end, *buf = NULL; int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/status", objbuf.get()); buf = readfile(pathbuf, &bytes_read, 1); @@ -790,9 +790,9 @@ void print_pid_fsgid(struct text_object *obj, char *p, int p_max_size) { char *begin, *end, *buf = NULL; int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/status", objbuf.get()); buf = readfile(pathbuf, &bytes_read, 1); @@ -819,9 +819,9 @@ void internal_print_pid_vm(struct text_object *obj, char *p, int p_max_size, con char *begin, *end, *buf = NULL; int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/status", objbuf.get()); buf = readfile(pathbuf, &bytes_read, 1); @@ -890,9 +890,9 @@ void print_pid_read(struct text_object *obj, char *p, int p_max_size) { char *begin, *end, *buf = NULL; int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/io", objbuf.get()); buf = readfile(pathbuf, &bytes_read, 1); @@ -917,9 +917,9 @@ void print_pid_write(struct text_object *obj, char *p, int p_max_size) { char *begin, *end, *buf = NULL; int bytes_read; char pathbuf[64]; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); snprintf(pathbuf, 64, PROCDIR "/%s/io", objbuf.get()); buf = readfile(pathbuf, &bytes_read, 1); diff --git a/src/scroll.cc b/src/scroll.cc index fb88c3a8..26edf15b 100644 --- a/src/scroll.cc +++ b/src/scroll.cc @@ -110,12 +110,12 @@ void print_scroll(struct text_object *obj, char *p, int p_max_size) struct scroll_data *sd = (struct scroll_data *)obj->data.opaque; unsigned int j, colorchanges = 0, frontcolorchanges = 0, visibcolorchanges = 0, strend; char *pwithcolors; - std::vector buf(max_user_text); + std::vector buf(max_user_text.get(*state)); if (!sd) return; - generate_text_internal(&(buf[0]), max_user_text, *obj->sub); + generate_text_internal(&(buf[0]), max_user_text.get(*state), *obj->sub); for(j = 0; buf[j] != 0; j++) { switch(buf[j]) { case '\n': //place all the lines behind each other with LINESEPARATOR between them diff --git a/src/timeinfo.cc b/src/timeinfo.cc index bd769a36..02c3d751 100644 --- a/src/timeinfo.cc +++ b/src/timeinfo.cc @@ -311,9 +311,9 @@ static void do_format_time(struct text_object *obj, char *p, unsigned int p_max_ void print_format_time(struct text_object *obj, char *p, int p_max_size) { - std::unique_ptr buf(new char[max_user_text]); + std::unique_ptr buf(new char[max_user_text.get(*state)]); - generate_text_internal(buf.get(), max_user_text, *obj->sub); + generate_text_internal(buf.get(), max_user_text.get(*state), *obj->sub); obj->data.s = buf.get(); do_format_time(obj, p, p_max_size); } diff --git a/src/user.cc b/src/user.cc index 49d9e398..2b463714 100644 --- a/src/user.cc +++ b/src/user.cc @@ -39,9 +39,9 @@ void print_uid_name(struct text_object *obj, char *p, int p_max_size) { struct passwd *pw; uid_t uid; char* firstinvalid; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); errno = 0; uid = strtol(objbuf.get(), &firstinvalid, 10); @@ -61,9 +61,9 @@ void print_gid_name(struct text_object *obj, char *p, int p_max_size) { struct group *grp; gid_t gid; char* firstinvalid; - std::unique_ptr objbuf(new char[max_user_text]); + std::unique_ptr objbuf(new char[max_user_text.get(*state)]); - generate_text_internal(objbuf.get(), max_user_text, *obj->sub); + generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub); errno = 0; gid = strtol(objbuf.get(), &firstinvalid, 10);