[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/22] ui/vnc: simplify and avoid strncpy
From: |
Jim Meyering |
Subject: |
[Qemu-devel] [PATCH 09/22] ui/vnc: simplify and avoid strncpy |
Date: |
Wed, 9 May 2012 11:23:53 +0200 |
From: Jim Meyering <address@hidden>
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 <address@hidden>
---
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.7.10.1.487.ga3935e6
- [Qemu-devel] strncpy: best avoided (resend), Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 09/22] ui/vnc: simplify and avoid strncpy,
Jim Meyering <=
- [Qemu-devel] [PATCH 10/22] bt: replace fragile snprintf use and unwarranted strncpy, Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 12/22] virtio-9p: avoid unwarranted use of strncpy, Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 06/22] os-posix: avoid buffer overrun, Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 01/22] block: avoid buffer overrun by using pstrcpy, not strncpy, Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 18/22] acpi: remove strzcpy (strncpy-identical) function; just use strncpy, Jim Meyering, 2012/05/09