Просмотр исходного кода

ipc_glue: Fix strncpy in pid_to_name function

Trailing zero is always added so there is no need to have a warning
about unterminated destination string.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
(cherry picked from commit 0095b9a3cb27b4349b013bdb1f551b322f048c76)
Jan Friesse 7 лет назад
Родитель
Сommit
078af63457
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      exec/ipc_glue.c

+ 1 - 1
exec/ipc_glue.c

@@ -250,7 +250,7 @@ static char * pid_to_name (pid_t pid, char *out_name, size_t name_len)
 	rest += 2;
 
 	/* copy the name */
-	strncpy (out_name, name, name_len);
+	strncpy (out_name, name, name_len - 1);
 	out_name[name_len - 1] = '\0';
 	return out_name;
 }