WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] ioemu: Improve xenstore_read_vncpasswd().

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] ioemu: Improve xenstore_read_vncpasswd().
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 24 Jan 2008 07:10:15 -0800
Delivery-date: Thu, 24 Jan 2008 07:11:32 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1201185226 0
# Node ID edc268331a9e6233764f84860a62d0030f25835a
# Parent  db620f1c9d3077e732440d1088e608b6d5530daa
ioemu: Improve xenstore_read_vncpasswd().
From: Peter Johnston <peter.johnston@xxxxxxxxxx>
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 tools/ioemu/xenstore.c |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff -r db620f1c9d30 -r edc268331a9e tools/ioemu/xenstore.c
--- a/tools/ioemu/xenstore.c    Thu Jan 24 14:29:13 2008 +0000
+++ b/tools/ioemu/xenstore.c    Thu Jan 24 14:33:46 2008 +0000
@@ -492,7 +492,7 @@ void xenstore_read_vncpasswd(int domid, 
 void xenstore_read_vncpasswd(int domid, char *pwbuf, size_t pwbuflen)
 {
     char *buf = NULL, *path, *uuid = NULL, *passwd = NULL;
-    unsigned int i, len, rc = 0;
+    unsigned int i, len;
 
     pwbuf[0] = '\0';
 
@@ -506,33 +506,38 @@ void xenstore_read_vncpasswd(int domid, 
     }
 
     pasprintf(&buf, "%s/vm", path);
+    free(path);
     uuid = xs_read(xsh, XBT_NULL, buf, &len);
     if (uuid == NULL) {
         fprintf(logfile, "xs_read(): uuid get error. %s.\n", buf);
-        free(path);
+        free(buf);
         return;
     }
 
     pasprintf(&buf, "%s/vncpasswd", uuid);
+    free(uuid);
     passwd = xs_read(xsh, XBT_NULL, buf, &len);
     if (passwd == NULL) {
         fprintf(logfile, "xs_read(): vncpasswd get error. %s.\n", buf);
-        free(uuid);
-        free(path);
+        free(buf);
         return;
     }
 
-    for (i=0; i<len && i<pwbuflen; i++)
+    if (len >= pwbuflen)
+    {
+        fprintf(logfile, "xenstore_read_vncpasswd(): truncated password to 
avoid buffer overflow\n");
+        len = pwbuflen - 1;
+    }
+
+    for (i=0; i<len; i++)
         pwbuf[i] = passwd[i];
-    pwbuf[len < (pwbuflen-1) ? len : (pwbuflen-1)] = '\0';
+    pwbuf[len] = '\0';
     passwd[0] = '\0';
-    pasprintf(&buf, "%s/vncpasswd", uuid);
-    if (xs_write(xsh, XBT_NULL, buf, passwd, len) == 0)
+    if (xs_write(xsh, XBT_NULL, buf, passwd, 1) == 0)
         fprintf(logfile, "xs_write() vncpasswd failed.\n");
 
     free(passwd);
-    free(uuid);
-    free(path);
+    free(buf);
 }
 
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] ioemu: Improve xenstore_read_vncpasswd()., Xen patchbot-unstable <=