1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-27 09:08:25 +00:00

fix new_graph parameters

One should never print into buffers without knowing their size. Although
new_graph consumes only a single char, this may already be too much.
This commit is contained in:
Phil Sutter 2009-11-22 21:12:54 +01:00
parent 346b4cfbc1
commit 970420106c
9 changed files with 16 additions and 16 deletions

View File

@ -464,8 +464,8 @@ void scan_loadgraph_arg(struct text_object *obj, const char *arg)
free(buf);
}
void print_loadgraph(struct text_object *obj, char *p)
void print_loadgraph(struct text_object *obj, char *p, int p_max_size)
{
new_graph(obj, p, info.loadavg[0]);
new_graph(obj, p, p_max_size, info.loadavg[0]);
}
#endif /* X11 */

View File

@ -72,7 +72,7 @@ void scan_loadavg_arg(struct text_object *, const char *);
void print_loadavg(struct text_object *, char *, int);
#ifdef X11
void scan_loadgraph_arg(struct text_object *, const char *);
void print_loadgraph(struct text_object *, char *);
void print_loadgraph(struct text_object *, char *, int);
#endif /* X11 */
#endif /* _COMMON_H */

View File

@ -902,10 +902,10 @@ void generate_text_internal(char *p, int p_max_size,
}
#ifdef X11
OBJ(cpugraph) {
new_graph(obj, p, round_to_int(cur->cpu_usage[obj->data.i] * 100));
new_graph(obj, p, p_max_size, round_to_int(cur->cpu_usage[obj->data.i] * 100));
}
OBJ(loadgraph) {
print_loadgraph(obj, p);
print_loadgraph(obj, p, p_max_size);
}
#endif /* X11 */
OBJ(color) {
@ -1373,7 +1373,7 @@ void generate_text_internal(char *p, int p_max_size,
}
#ifdef X11
OBJ(memgraph) {
new_graph(obj, p, cur->memmax ? (cur->mem * 100.0) / (cur->memmax) : 0.0);
new_graph(obj, p, p_max_size, cur->memmax ? (cur->mem * 100.0) / (cur->memmax) : 0.0);
}
#endif /* X11 */
/* mixer stuff */
@ -2325,7 +2325,7 @@ void generate_text_internal(char *p, int p_max_size,
OBJ(apcupsd_loadgraph) {
double progress;
progress = atof(cur->apcupsd.items[APCUPSD_LOAD]);
new_graph(obj, p, (int)progress);
new_graph(obj, p, p_max_size, (int)progress);
}
#endif /* X11 */
OBJ(apcupsd_loadgauge) {

View File

@ -183,7 +183,7 @@ static void print_diskiograph_dir(struct text_object *obj, int dir, char *p, int
else
val = diskio->current_write;
new_graph(obj, p, val);
new_graph(obj, p, p_max_size, val);
}
void print_diskiograph(struct text_object *obj, char *p, int p_max_size)

View File

@ -387,7 +387,7 @@ void print_execgraph(struct text_object *obj, char *p, int p_max_size)
barnum = get_barnum(p);
if (barnum > 0) {
new_graph(obj, p, round_to_int(barnum));
new_graph(obj, p, p_max_size, round_to_int(barnum));
}
}
@ -409,7 +409,7 @@ void print_execigraph(struct text_object *obj, char *p, int p_max_size)
}
ed->last_update = current_update_time;
}
new_graph(obj, p, (int) (ed->barnum));
new_graph(obj, p, p_max_size, (int) (ed->barnum));
}
#endif /* X11 */

View File

@ -563,7 +563,7 @@ void print_lua_graph(struct text_object *obj, char *p, int p_max_size)
return;
if (llua_getnumber(obj->data.s, &per)) {
new_graph(obj, p, per);
new_graph(obj, p, p_max_size, per);
}
}
#endif /* X11 */

View File

@ -213,7 +213,7 @@ void print_downspeedgraph(struct text_object *obj, char *p, int p_max_size)
if (!ns || !p_max_size)
return;
new_graph(obj, p, ns->recv_speed / 1024.0);
new_graph(obj, p, p_max_size, ns->recv_speed / 1024.0);
}
void print_upspeedgraph(struct text_object *obj, char *p, int p_max_size)
@ -223,7 +223,7 @@ void print_upspeedgraph(struct text_object *obj, char *p, int p_max_size)
if (!ns || !p_max_size)
return;
new_graph(obj, p, ns->trans_speed / 1024.0);
new_graph(obj, p, p_max_size, ns->trans_speed / 1024.0);
}
#endif /* X11 */

View File

@ -339,7 +339,7 @@ static void graph_append(struct special_t *graph, double f, char showaslog)
}
}
void new_graph(struct text_object *obj, char *buf, double val)
void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
{
struct special_t *s = 0;
struct graph *g = obj->special_data;
@ -347,7 +347,7 @@ void new_graph(struct text_object *obj, char *buf, double val)
if ((output_methods & TO_X) == 0)
return;
if (!g)
if (!g || !buf_max_size)
return;
s = new_special(buf, GRAPH);

View File

@ -104,7 +104,7 @@ void scan_stippled_hr(struct text_object *, const char*);
/* printing specials */
void new_font(char *, char *);
void new_graph(struct text_object *, char *, double);
void new_graph(struct text_object *, char *, int, double);
void new_hr(char *, int);
void new_stippled_hr(struct text_object *, char *);
#endif