Check for zero-length $HOME and document the reason flawfinder's warning is being ignored.

This commit is contained in:
Andrew Wood
2024-04-20 21:01:04 +01:00
parent 1ad9c321bc
commit 8bc1cc28d0
+6
View File
@@ -84,6 +84,12 @@ static FILE *pv__control_file(char *filename, size_t bufsize, pid_t control_pid,
home_dir = getenv("HOME"); /* flawfinder: ignore */
if (NULL == home_dir)
return NULL;
if ('\0' == home_dir[0])
return NULL;
/* flawfinder rationale: null and zero-size values are
* rejected, and the destination buffer is bounded.
*/
(void) pv_snprintf(filename, bufsize, "%s/.pv/remote.%lu", home_dir, (unsigned long) control_pid);
control_fd = open(filename, open_flags, open_mode); /* flawfinder: ignore */