소스 검색

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>
Jan Friesse 7 년 전
부모
커밋
0095b9a3cb
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      exec/ipc_glue.c

+ 1 - 1
exec/ipc_glue.c

@@ -254,7 +254,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;
 }