Received: from eggs.gnu.org ([208.118.235.92]:59472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJjKx-0002Mb-QZ for qemu-devel@nongnu.org; Thu, 04 Oct 2012 07:11:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TJjKr-0003OT-FZ for qemu-devel@nongnu.org; Thu, 04 Oct 2012 07:11:27 -0400 Received: from mx.meyering.net ([88.168.87.75]:57025 helo=hx.meyering.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJjKr-0003O9-2W for qemu-devel@nongnu.org; Thu, 04 Oct 2012 07:11:21 -0400 From: Jim Meyering Date: Thu, 4 Oct 2012 13:09:54 +0200 Message-Id: <1349349003-15672-12-git-send-email-jim@meyering.net> In-Reply-To: <1349349003-15672-1-git-send-email-jim@meyering.net> References: <1349349003-15672-1-git-send-email-jim@meyering.net> Subject: [Qemu-devel] [PATCHv3 11/20] ui/vnc: simplify and avoid strncpy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jim Meyering From: Jim Meyering Don't bother with strncpy. There's no need for its zero-fill. Use g_strndup in place of g_malloc+strncpy+NUL-terminate. Signed-off-by: Jim Meyering --- ui/vnc-auth-sasl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c index 8fba770..bfdcb46 100644 --- a/ui/vnc-auth-sasl.c +++ b/ui/vnc-auth-sasl.c @@ -432,9 +432,7 @@ static int protocol_client_auth_sasl_start_len(VncState *vs, uint8_t *data, size static int protocol_client_auth_sasl_mechname(VncState *vs, uint8_t *data, size_t len) { - char *mechname = g_malloc(len + 1); - strncpy(mechname, (char*)data, len); - mechname[len] = '\0'; + char *mechname = g_strndup((const char *) data, len); VNC_DEBUG("Got client mechname '%s' check against '%s'\n", mechname, vs->sasl.mechlist); -- 1.8.0.rc0.18.gf84667d