Skip to contentSkip to conversation

Fix fd leak in vvfat.c and strncmp() issue in vnc.c

PATCH Applied Stefan Hajnoczi 2 participants 4 messages Jan 6, 2012 – Jan 12, 2012 Block layer

lore
Share & tools
lore
#2 lore raw

PATCH 2/2 vnc: fix no-lock-key-sync strncmp() length

In reply to Stefan Hajnoczi

The no-lock-key-sync option is being parsed incorrectly because of an outdated strcmp() length value. Use the correct length so that invalid option names do not match.

---
 ui/vnc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
ui/vnc.c +1 -1
index 6767ada..1869a7a 100644
@@ -2763,7 +2763,7 @@ int vnc_display_open(DisplayState *ds, const char *display)
             password = 1; /* Require password auth */
         } else if (strncmp(options, "reverse", 7) == 0) {
             reverse = 1;
-        } else if (strncmp(options, "no-lock-key-sync", 9) == 0) {
+        } else if (strncmp(options, "no-lock-key-sync", 16) == 0) {
             lock_key_sync = 0;
 #ifdef CONFIG_VNC_SASL
         } else if (strncmp(options, "sasl", 4) == 0) {
Signature · 1 line
1.7.7.3
#1 lore raw

PATCH 1/2 vvfat: avoid leaking file descriptor in commit_one_file()

In reply to Stefan Hajnoczi
---
 block/vvfat.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
block/vvfat.c +3 -0
index eeffc4a..9ef21dd 100644
@@ -2218,6 +2218,7 @@ static int commit_one_file(BDRVVVFATState* s,
     }
     if (offset > 0) {
         if (lseek(fd, offset, SEEK_SET) != offset) {
+            close(fd);
             g_free(cluster);
             return -3;
         }
@@ -2238,11 +2239,13 @@ static int commit_one_file(BDRVVVFATState* s,
 	    (uint8_t*)cluster, (rest_size + 0x1ff) / 0x200);
 
         if (ret < 0) {
+            close(fd);
             g_free(cluster);
             return ret;
         }
 
         if (write(fd, cluster, rest_size) < 0) {
+            close(fd);
             g_free(cluster);
             return -2;
         }
Signature · 1 line
1.7.7.3
#0 lore raw

cover Fix fd leak in vvfat.c and strncmp() issue in vnc.c

Two unrelated bugs that David Gilbert had kicking around that are easy to fix. Let's take care of them.

Stefan Hajnoczi (2):
vvfat: avoid leaking file descriptor in commit_one_file()
vnc: fix no-lock-key-sync strncmp() length

 block/vvfat.c |    3 +++
 ui/vnc.c      |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)
Signature · 1 line
1.7.7.3
#3 lore raw
Quoted 10 lines · Stefan Hajnoczi

Two unrelated bugs that David Gilbert had kicking around that are easy to fix. Let's take care of them.

Stefan Hajnoczi (2):
vvfat: avoid leaking file descriptor in commit_one_file()
vnc: fix no-lock-key-sync strncmp() length

 block/vvfat.c |    3 +++
 ui/vnc.c      |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)

Applied to the trivial patches tree.

Stefan