From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhgED-0004q5-S5 for qemu-devel@nongnu.org; Thu, 01 Oct 2015 11:57:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZhgED-000173-1F for qemu-devel@nongnu.org; Thu, 01 Oct 2015 11:57:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33344) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhgEC-00016x-Ss for qemu-devel@nongnu.org; Thu, 01 Oct 2015 11:57:04 -0400 References: From: Eric Blake Message-ID: <560D57CF.1040401@redhat.com> Date: Thu, 1 Oct 2015 09:57:03 -0600 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="mc4epEcKS6uET4Evp3rDqvQDEHbwjF4e2" Subject: Re: [Qemu-devel] [PATCH v2] linux-user/syscall.c: malloc()/calloc() to g_malloc()/g_try_malloc()/g_new0() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Harmandeep Kaur , qemu-devel Cc: Stefan Hajnoczi , Riku Voipio This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --mc4epEcKS6uET4Evp3rDqvQDEHbwjF4e2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/30/2015 11:32 PM, Harmandeep Kaur wrote: > Convert malloc()/calloc() calls to g_malloc()/g_try_malloc()/g_new0() > in linux-user/syscall.c file This part is fine, >=20 > v1->v2 convert the free() call in host_to_target_semarray() > to g_free() and calls g_try_malloc(count) instead of > g_try_malloc(sizeof(count)) but this part belongs... >=20 > Signed-off-by: Harmandeep Kaur > --- =2E..here, after the --- separator. It is useful information to mail reviewers, but worthless in the qemu.git history (a year from now, we won't care how many versions it went through on the list, only the version that got checked in). > +++ b/linux-user/syscall.c > @@ -1554,12 +1554,7 @@ set_timeout: > } >=20 > fprog.len =3D tswap16(tfprog->len); > - filter =3D malloc(fprog.len * sizeof(*filter)); > - if (filter =3D=3D NULL) { > - unlock_user_struct(tfilter, tfprog->filter, 1); > - unlock_user_struct(tfprog, optval_addr, 1); > - return -TARGET_ENOMEM; > - } > + filter =3D g_malloc(fprog.len * sizeof(*filter)); This should use g_new(TYPE, fprog.len) to avoid overflow issues. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --mc4epEcKS6uET4Evp3rDqvQDEHbwjF4e2 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWDVfPAAoJEKeha0olJ0NqOHAH/2JSfQG33ALz6opptAZ+Mux+ OjBfI6XQqMg8Oy2RqzdaRtSSmssTEAA3/mYHwQD9CU7GpzydmhSsFLznaXA4gzVI FSDMBlinNuuj8ABS40TPZ6zeZabjfZgUw1srsJEaiIEUQHArAUx9aj+RcMujhgeP CSt+JIYwbuMgCmbKpq98ME2mJ2jaya3foabERQ4BzqX3qf3o9f+koXE9kGa0V6KJ EfC+PPEqcLq4K296sdhWxc3lxkIZ7I/+v8DOxuij3NLFFg9Fs0msCSpEfC20woqb lMVvcvRqLfKwDFEgn/oq1IpRn+4IhBtyxLF1Sqc7rBhriSmGgORGEEMk17NJ1Vk= =T+Q4 -----END PGP SIGNATURE----- --mc4epEcKS6uET4Evp3rDqvQDEHbwjF4e2--