[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 1 of 4] Fix off-by-one preventing the last elfnote from being read in xc.c



On Tue, 2007-02-27 at 22:38 -0800, Brendan Cully wrote:
> # HG changeset patch
> # User Brendan Cully <brendan@xxxxxxxxx>
> # Date 1172644688 28800
> # Node ID a7afd4050ce3201044ac8fec1b4469d758a0fc80
> # Parent  1c5e6239a8d0381fdbf56d4926f986d7f0ec07c0
> Fix off-by-one preventing the last elfnote from being read in xc.c.
> 
> Signed-off-by: Brendan Cully <brendan@xxxxxxxxx>
> 
> diff -r 1c5e6239a8d0 -r a7afd4050ce3 tools/python/xen/lowlevel/xc/xc.c
> --- a/tools/python/xen/lowlevel/xc/xc.c       Sun Feb 25 23:58:33 2007 -0600
> +++ b/tools/python/xen/lowlevel/xc/xc.c       Tue Feb 27 22:38:08 2007 -0800
> @@ -411,7 +411,7 @@ static PyObject *pyxc_linux_build(XcObje
>  
>      if (!(elfnote_dict = PyDict_New()))
>       goto out;
> -    for (i = 0; i < XEN_ELFNOTE_MAX; i++) {
> +    for (i = 0; i <= XEN_ELFNOTE_MAX; i++) {
>       switch (dom->parms.elf_notes[i].type) {
>       case XEN_ENT_NONE:
>           continue;

I think we should rename XEN_ELFNOTE_MAX to XEN_ELFNOTE_NR (and +1)
which would be clearer IMHO. The only other place it used is
"XEN_ELFNOTE_MAX + 1" anyway:

--- 
Change XEN_ELFNOTE_MAX to XEN_ELFNOTE_NR and make it the number of ELF
notes rather than the index of the last ELF note.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxxxxx>
diff -r 5217185f7588 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Tue Feb 27 20:27:18 2007 +0000
+++ b/tools/python/xen/lowlevel/xc/xc.c Wed Feb 28 08:59:41 2007 +0000
@@ -411,7 +411,7 @@ static PyObject *pyxc_linux_build(XcObje
 
     if (!(elfnote_dict = PyDict_New()))
        goto out;
-    for (i = 0; i < XEN_ELFNOTE_MAX; i++) {
+    for (i = 0; i < XEN_ELFNOTE_NR; i++) {
        switch (dom->parms.elf_notes[i].type) {
        case XEN_ENT_NONE:
            continue;
diff -r 5217185f7588 xen/include/public/elfnote.h
--- a/xen/include/public/elfnote.h      Tue Feb 27 20:27:18 2007 +0000
+++ b/xen/include/public/elfnote.h      Wed Feb 28 09:03:30 2007 +0000
@@ -157,9 +157,9 @@
 #define XEN_ELFNOTE_L1_MFN_VALID  13
 
 /*
- * The number of the highest elfnote defined.
- */
-#define XEN_ELFNOTE_MAX XEN_ELFNOTE_L1_MFN_VALID
+ * The number of elfnotes defined.
+ */
+#define XEN_ELFNOTE_NR (XEN_ELFNOTE_L1_MFN_VALID + 1)
 
 /*
  * System information exported through crash notes.
diff -r 5217185f7588 xen/include/public/libelf.h
--- a/xen/include/public/libelf.h       Tue Feb 27 20:27:18 2007 +0000
+++ b/xen/include/public/libelf.h       Wed Feb 28 08:59:23 2007 +0000
@@ -195,7 +195,7 @@ struct elf_dom_parms {
     const char *guest_info;
     const void *elf_note_start;
     const void *elf_note_end;
-    struct xen_elfnote elf_notes[XEN_ELFNOTE_MAX + 1];
+    struct xen_elfnote elf_notes[XEN_ELFNOTE_NR];
   
     /* parsed */
     char guest_os[16];



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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.