From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:58881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RR4AN-0001E0-DQ for qemu-devel@nongnu.org; Thu, 17 Nov 2011 10:46:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RR4AH-00029A-P8 for qemu-devel@nongnu.org; Thu, 17 Nov 2011 10:46:19 -0500 Received: from mail-ww0-f53.google.com ([74.125.82.53]:45176) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RR4AH-000296-Jw for qemu-devel@nongnu.org; Thu, 17 Nov 2011 10:46:13 -0500 Received: by wwf27 with SMTP id 27so2860569wwf.10 for ; Thu, 17 Nov 2011 07:46:12 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <1321358265-10924-5-git-send-email-mohan@in.ibm.com> References: <1321358265-10924-1-git-send-email-mohan@in.ibm.com> <1321358265-10924-5-git-send-email-mohan@in.ibm.com> Date: Thu, 17 Nov 2011 15:46:12 +0000 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH V2 04/12] hw/9pfs: Open and create files List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "M. Mohan Kumar" Cc: qemu-devel@nongnu.org, aneesh.kumar@linux.vnet.ibm.com On Tue, Nov 15, 2011 at 11:57 AM, M. Mohan Kumar wrote: > +static void send_fd(int sockfd, int fd) > +{ > + =A0 =A0struct msghdr msg =3D { }; > + =A0 =A0struct iovec iov; > + =A0 =A0struct cmsghdr *cmsg; > + =A0 =A0int retval, data; > + =A0 =A0union MsgControl msg_control; > + > + =A0 =A0iov.iov_base =3D &data; > + =A0 =A0iov.iov_len =3D sizeof(data); > + > + =A0 =A0memset(&msg, 0, sizeof(msg)); > + =A0 =A0msg.msg_iov =3D &iov; > + =A0 =A0msg.msg_iovlen =3D 1; > + =A0 =A0/* No ancillary data on error */ > + =A0 =A0if (fd < 0) { > + =A0 =A0 =A0 =A0/* > + =A0 =A0 =A0 =A0 * fd is really negative errno if the request failed. Or= simply > + =A0 =A0 =A0 =A0 * zero if the request is successful and it doesn't need= a file > + =A0 =A0 =A0 =A0 * descriptor. > + =A0 =A0 =A0 =A0 */ It cannot be zero because the if statement is fd < 0. The comment is confu= sing. > +/* > + * create a file and send fd on success > + * return -errno on error > + */ > +static int do_create(struct iovec *iovec) > +{ > + =A0 =A0V9fsString path; > + =A0 =A0int flags, fd, mode, uid, gid, cur_uid, cur_gid; > + =A0 =A0proxy_unmarshal(iovec, 1, HDR_SZ, "sdddd", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &path, &flags, &mode, &uid, &gid); Unmarshalling can fail if the iovec size does not match what the format string describes. We should fail here rather than continuing on. If execution continues some of the variables may be uninitialized. Stefan