From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LhPpu-0005qO-Qj for qemu-devel@nongnu.org; Wed, 11 Mar 2009 10:55:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LhPps-0005pG-I2 for qemu-devel@nongnu.org; Wed, 11 Mar 2009 10:55:09 -0400 Received: from [199.232.76.173] (port=57887 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LhPps-0005p2-8H for qemu-devel@nongnu.org; Wed, 11 Mar 2009 10:55:08 -0400 Received: from mx1.redhat.com ([66.187.233.31]:50125) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LhPpr-0006V8-LS for qemu-devel@nongnu.org; Wed, 11 Mar 2009 10:55:07 -0400 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n2BEt7qC025063 for ; Wed, 11 Mar 2009 10:55:07 -0400 Received: from file.fab.redhat.com (file.fab.redhat.com [10.33.63.6]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n2BEtBAY007475 for ; Wed, 11 Mar 2009 10:55:11 -0400 Received: from file.fab.redhat.com (localhost.localdomain [127.0.0.1]) by file.fab.redhat.com (8.13.1/8.13.1) with ESMTP id n2BEt6qS017157 for ; Wed, 11 Mar 2009 14:55:06 GMT Received: (from berrange@localhost) by file.fab.redhat.com (8.13.1/8.13.1/Submit) id n2BEt6Ht017131 for qemu-devel@nongnu.org; Wed, 11 Mar 2009 14:55:06 GMT Date: Wed, 11 Mar 2009 14:55:06 +0000 From: "Daniel P. Berrange" Message-ID: <20090311145506.GM23995@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] PATCH: Replace asprintf() with snprintf() in vnc.c Reply-To: "Daniel P. Berrange" , qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org As previously discussed, this patch removes the non-portable use of asprintf(), replacing it with malloc+snprintf instead Signed-off-by: Daniel P. Berrange Daniel Index: vnc.c =================================================================== --- vnc.c (revision 6811) +++ vnc.c (working copy) @@ -53,6 +53,7 @@ char host[NI_MAXHOST]; char serv[NI_MAXSERV]; int err; + size_t addrlen; if ((err = getnameinfo((struct sockaddr *)sa, salen, host, sizeof(host), @@ -63,8 +64,12 @@ return NULL; } - if (asprintf(&addr, format, host, serv) < 0) - return NULL; + /* Enough for the existing format + the 2 vars we're + * subsituting in. */ + addrlen = strlen(format) + strlen(host) + strlen(serv); + addr = qemu_malloc(addrlen + 1); + snprintf(addr, addrlen, format, host, serv); + addr[addrlen] = '\0'; return addr; } -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|