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
					
				@ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user