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:
Jim Meyering authored and Anthony Liguori committed 2012-10-05 07:58:37 -05:00
1 parent 900cfbcac6
commit 5847d9e139
1 file changed
+1 -3
+1 -3
View File
@@ -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);