From: jsg Date: Mon, 13 May 2024 06:48:26 +0000 (+0000) Subject: fix some leaks; ok op@ X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8e996a8e97c7e612ed9d362e431f1b8d4939e244;p=openbsd fix some leaks; ok op@ --- diff --git a/usr.sbin/smtpd/smtpc.c b/usr.sbin/smtpd/smtpc.c index 915206a6908..33d84c7c574 100644 --- a/usr.sbin/smtpd/smtpc.c +++ b/usr.sbin/smtpd/smtpc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpc.c,v 1.20 2023/05/16 17:48:52 op Exp $ */ +/* $OpenBSD: smtpc.c,v 1.21 2024/05/13 06:48:26 jsg Exp $ */ /* * Copyright (c) 2018 Eric Faurot @@ -399,6 +399,7 @@ parse_message(FILE *ifp) fatal("fputc"); } + free(line); fclose(ifp); rewind(mail.fp); } diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c index e2e03222ab3..5c08cd49ed0 100644 --- a/usr.sbin/smtpd/util.c +++ b/usr.sbin/smtpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.157 2024/05/02 18:14:33 op Exp $ */ +/* $OpenBSD: util.c,v 1.158 2024/05/13 06:48:26 jsg Exp $ */ /* * Copyright (c) 2000,2001 Markus Friedl. All rights reserved. @@ -744,22 +744,24 @@ parse_mailname_file(char *hostname, size_t len) if ((fp = fopen(MAILNAME_FILE, "r")) == NULL) return 1; - if ((buflen = getline(&buf, &bufsz, fp)) == -1) - goto error; + buflen = getline(&buf, &bufsz, fp); + fclose(fp); + if (buflen == -1) { + free(buf); + return 1; + } if (buf[buflen - 1] == '\n') buf[buflen - 1] = '\0'; - if (strlcpy(hostname, buf, len) >= len) { + bufsz = strlcpy(hostname, buf, len); + free(buf); + if (bufsz >= len) { fprintf(stderr, MAILNAME_FILE " entry too long"); - goto error; + return 1; } return 0; -error: - fclose(fp); - free(buf); - return 1; } int