snprintf already guarantees \0 terminated strings for size arguments is > 0.
Reported-by: Anatoliy Lapitskiy anatoliy.lapitskiy@gmail.com Signed-off-by: Sven Eckelmann sven@narfation.org --- debugfs.c | 1 - vis/vis.c | 3 --- 2 files changed, 4 deletions(-)
diff --git a/debugfs.c b/debugfs.c index fbf992e..6404b49 100644 --- a/debugfs.c +++ b/debugfs.c @@ -58,7 +58,6 @@ int debugfs_make_path(const char *fmt, const char *mesh_iface, char *buffer, return len+1;
snprintf(buffer, size-1, fmt, debugfs_mountpoint, mesh_iface); - buffer[size - 1] = '\0'; return 0; }
diff --git a/vis/vis.c b/vis/vis.c index 4a14e66..c1f8dad 100644 --- a/vis/vis.c +++ b/vis/vis.c @@ -274,7 +274,6 @@ static int register_interfaces(struct globals *globals)
while ((iface_dir = readdir(iface_base_dir)) != NULL) { snprintf(path_buff, PATH_BUFF_LEN, SYS_MESH_IFACE_FMT, iface_dir->d_name); - path_buff[PATH_BUFF_LEN - 1] = '\0'; file_content = read_file(path_buff); if (!file_content) continue; @@ -292,7 +291,6 @@ static int register_interfaces(struct globals *globals) file_content = NULL;
snprintf(path_buff, PATH_BUFF_LEN, SYS_IFACE_STATUS_FMT, iface_dir->d_name); - path_buff[PATH_BUFF_LEN - 1] = '\0'; file_content = read_file(path_buff); if (!file_content) continue; @@ -328,7 +326,6 @@ static int parse_orig_list(struct globals *globals) struct vis_list_entry *v_entry;
snprintf(path, sizeof(path), "/sys/kernel/debug/batman_adv/%s/originators", globals->interface); - path[sizeof(path) - 1] = 0; fbuf = read_file(path); if (!fbuf) return -1;
On Tuesday 17 March 2015 08:47:29 Sven Eckelmann wrote:
snprintf already guarantees \0 terminated strings for size arguments is > 0.
Reported-by: Anatoliy Lapitskiy anatoliy.lapitskiy@gmail.com Signed-off-by: Sven Eckelmann sven@narfation.org
Applied in revision f7914a8.
Thanks! Simon
b.a.t.m.a.n@lists.open-mesh.org