diff --git a/qemu/monitor.c b/qemu/monitor.c
index 1b2adc8..7bbb457 100644
--- a/qemu/monitor.c
+++ b/qemu/monitor.c
@@ -466,8 +466,13 @@ static void do_change_vnc(const char *target, const char
*arg)
strcmp(target, "password") == 0) {
char password[9];
if (arg) {
- strncpy(password, arg, sizeof(password));
- password[sizeof(password) - 1] = '\0';
+ /* "<<unset>>" is 9 chars long, so it is not a valid VNC passwd. */
+ if (strcmp(arg, "<<unset>>") == 0) {
+ password[0] = '\0';
+ } else {
+ strncpy(password, arg, sizeof(password));
+ password[sizeof(password) - 1] = '\0';
+ }
} else
monitor_readline("Password: ", 1, password, sizeof(password));
if (vnc_display_password(NULL, password) < 0)