diff --git a/hyptop/helper.h b/hyptop/helper.h index 2b581756..2d304789 100644 --- a/hyptop/helper.h +++ b/hyptop/helper.h @@ -17,6 +17,7 @@ #include #include "lib/util_base.h" +#include "lib/util_libc.h" #include "lib/zt_common.h" #define G0(x) MAX(0, (s64) (x)) diff --git a/hyptop/sd_core.c b/hyptop/sd_core.c index d83ff2c4..f1cb6314 100644 --- a/hyptop/sd_core.c +++ b/hyptop/sd_core.c @@ -219,7 +219,7 @@ struct sd_cpu *sd_cpu_new(struct sd_sys *parent, const char *id, cpu = ht_zalloc(sizeof(*cpu)); cpu->i.parent = parent; - strncpy(cpu->id, id, sizeof(cpu->id)); + util_strlcpy(cpu->id, id, sizeof(cpu->id)); cpu->type = l_cpu_type_by_id(type); cpu->d_cur = &cpu->d1; cpu->cnt = cnt; @@ -251,7 +251,7 @@ struct sd_sys *sd_sys_new(struct sd_sys *parent, const char *id) struct sd_sys *sys_new; sys_new = ht_zalloc(sizeof(*sys_new)); - strncpy(sys_new->id, id, sizeof(sys_new->id)); + util_strlcpy(sys_new->id, id, sizeof(sys_new->id)); util_list_init(&sys_new->child_list, struct sd_sys, list); util_list_init(&sys_new->cpu_list, struct sd_cpu, list); diff --git a/hyptop/table.c b/hyptop/table.c index e2de3812..a22754c7 100644 --- a/hyptop/table.c +++ b/hyptop/table.c @@ -47,7 +47,7 @@ static void l_mark_key_add(struct table *t, char *str) struct table_mark_key *key; key = ht_zalloc(sizeof(*key)); - strncpy(key->str, str, sizeof(key->str)); + util_strlcpy(key->str, str, sizeof(key->str)); util_list_add_tail(&t->mark_key_list, key); } @@ -617,7 +617,7 @@ void table_row_select_key_get(struct table *t, char str[TABLE_STR_MAX]) struct table_row *row; row = l_selected_row(t); - strncpy(str, row->entries[0].str, TABLE_STR_MAX); + util_strlcpy(str, row->entries[0].str, TABLE_STR_MAX); } /* diff --git a/hyptop/tbox.c b/hyptop/tbox.c index 515cb31e..861e98ce 100644 --- a/hyptop/tbox.c +++ b/hyptop/tbox.c @@ -157,7 +157,7 @@ static void l_print_line(const char *line) char line_cpy[TBOX_MAX_STR + 1]; char *ptr_old, *ptr; - strncpy(line_cpy, line, sizeof(line_cpy)); + util_strlcpy(line_cpy, line, sizeof(line_cpy)); ptr_old = ptr = line_cpy; do { ptr = strchr(ptr, '\\'); diff --git a/hyptop/win_sys.c b/hyptop/win_sys.c index ec03e93d..15311309 100644 --- a/hyptop/win_sys.c +++ b/hyptop/win_sys.c @@ -326,7 +326,7 @@ void win_sys_set(const char *sys_id) { if (l_initialized) table_reset(l_t); - strncpy(l_sys_id, sys_id, sizeof(l_sys_id)); + util_strlcpy(l_sys_id, sys_id, sizeof(l_sys_id)); } /*