[openssh-commits] [openssh] 05/05: upstream: memory leak on error path; bz3821

git+noreply at mindrot.org git+noreply at mindrot.org
Wed May 7 14:22:50 AEST 2025


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 93e904a673a632604525fdc98b940b7996f1ce54
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Wed May 7 04:10:21 2025 +0000

    upstream: memory leak on error path; bz3821
    
    OpenBSD-Commit-ID: 65577596a15ad6dd9a1ab3fc24c1c31303ee6e2b
---
 misc-agent.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/misc-agent.c b/misc-agent.c
index f13ccdf26..9d96880e9 100644
--- a/misc-agent.c
+++ b/misc-agent.c
@@ -266,10 +266,10 @@ socket_is_stale(const char *path)
 void
 agent_cleanup_stale(const char *homedir, int ignore_hosthash)
 {
-	DIR *d;
+	DIR *d = NULL;
 	struct dirent *dp;
 	struct stat sb;
-	char *prefix = NULL, *dirpath, *path;
+	char *prefix = NULL, *dirpath = NULL, *path;
 	struct timespec now, sub, *mtimp = NULL;
 
 	/* Only consider sockets last modified > 1 hour ago */
@@ -295,8 +295,7 @@ agent_cleanup_stale(const char *homedir, int ignore_hosthash)
 	if ((d = opendir(dirpath)) == NULL) {
 		if (errno != ENOENT)
 			error_f("opendir \"%s\": %s", dirpath, strerror(errno));
-		free(dirpath);
-		return;
+		goto out;
 	}
 	while ((dp = readdir(d)) != NULL) {
 		if (dp->d_type != DT_SOCK && dp->d_type != DT_UNKNOWN)
@@ -334,8 +333,9 @@ agent_cleanup_stale(const char *homedir, int ignore_hosthash)
 		}
 		free(path);
 	}
-	closedir(d);
+ out:
+	if (d != NULL)
+		closedir(d);
 	free(dirpath);
 	free(prefix);
 }
-

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list