From b70ec51c0d267271ae24ece4b145f5b945c45536 Mon Sep 17 00:00:00 2001 From: nicm <> Date: Wed, 7 Apr 2010 18:09:39 +0000 Subject: [PATCH] Remove XXX comment and just close received fd if calloc() fails. If this happens the imsg may no longer be usable as there may be queued messages, but this is a) already the case with the code now, and b) would be the case if recvmsg() fails anyway, so we can document that -1 from imsg_read() invalidates the struct imsgbuf. discussed with and ok eric --- src/usr.sbin/ntpd/imsg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/usr.sbin/ntpd/imsg.c b/src/usr.sbin/ntpd/imsg.c index 737175b8..43af5f85 100644 --- a/src/usr.sbin/ntpd/imsg.c +++ b/src/usr.sbin/ntpd/imsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg.c,v 1.18 2009/08/08 18:33:40 nicm Exp $ */ +/* $OpenBSD: imsg.c,v 1.19 2010/04/07 18:09:39 nicm Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -79,7 +79,7 @@ imsg_read(struct imsgbuf *ibuf) cmsg->cmsg_type == SCM_RIGHTS) { fd = (*(int *)CMSG_DATA(cmsg)); if ((ifd = calloc(1, sizeof(struct imsg_fd))) == NULL) { - /* XXX: this return can leak */ + close(fd); return (-1); } ifd->fd = fd;