mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
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>
This commit is contained in:
parent
900cfbcac6
commit
5847d9e139
1 changed files with 1 additions and 3 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue