mirror of
https://github.com/utmapp/qemu.git
synced 2026-12-01 22:23:23 -10: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 <[email protected]> Signed-off-by: Jim Meyering <[email protected]> Signed-off-by: Anthony Liguori <[email protected]>
This commit is contained in:
1 parent
900cfbcac6
commit
5847d9e139
1 file changed
+1
-3
+1
-3
@@ -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);
|
||||
|
||||
|
||||
Reference in new issue
Block a user