diff options
author | Jim Meyering <meyering@redhat.com> | 2012-10-04 13:09:54 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-10-05 07:58:37 -0500 |
commit | 5847d9e1399d3497be8eeca6f3a20a18a40b114b (patch) | |
tree | 0a94b172f4ab208649213b64da95264041337014 | |
parent | 900cfbcac6fa689b5fc8d53b60c3ed39047b8a33 (diff) | |
download | qemu-5847d9e1399d3497be8eeca6f3a20a18a40b114b.tar.gz qemu-5847d9e1399d3497be8eeca6f3a20a18a40b114b.tar.bz2 qemu-5847d9e1399d3497be8eeca6f3a20a18a40b114b.zip |
ui/vnc: simplify and avoid strncpy
Don't bother with strncpy. There's no need for its zero-fill.
Use g_strndup in place of g_malloc+strncpy+NUL-terminate.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | ui/vnc-auth-sasl.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c index 8fba7702c2..bfdcb46efe 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); |