[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCHv3 11/20] ui/vnc: simplify and avoid strncpy
From: |
Jim Meyering |
Subject: |
[Qemu-devel] [PATCHv3 11/20] ui/vnc: simplify and avoid strncpy |
Date: |
Thu, 4 Oct 2012 13:09:54 +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.8.0.rc0.18.gf84667d
- [Qemu-devel] [PATCHv3 02/20] sparc: use g_strdup in place of unchecked strdup, (continued)
- [Qemu-devel] [PATCHv3 02/20] sparc: use g_strdup in place of unchecked strdup, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 03/20] block: avoid buffer overrun by using pstrcpy, not strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 05/20] vmdk: relative_path: use pstrcpy in place of strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 06/20] hw/9pfs: avoid buffer overrun, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 04/20] sheepdog: avoid a few buffer overruns, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 07/20] lm32: avoid buffer overrun, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 10/20] linux-user: remove two unchecked uses of strdup, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 08/20] os-posix: avoid buffer overrun, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 09/20] ppc: avoid buffer overrun: use pstrcpy, not strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 12/20] bt: replace fragile snprintf use and unwarranted strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 11/20] ui/vnc: simplify and avoid strncpy,
Jim Meyering <=
- [Qemu-devel] [PATCHv3 15/20] qemu-ga: prefer pstrcpy: consistently NUL-terminate ifreq.ifr_name, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 16/20] libcacard/vcard_emul_nss: use pstrcpy in place of strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 13/20] virtio-9p: avoid unwarranted uses of strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 14/20] vscsi: avoid unwarranted strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 20/20] doc: update HACKING wrt strncpy/pstrcpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 18/20] qcow2: mark this file's sole strncpy use as justified, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 19/20] hw/r2d: add comment: this strncpy use is ok, Jim Meyering, 2012/10/04