]> xenbits.xensource.com Git - xen.git/commitdiff
libxc: Minor clean up of xc_core, and fix for -fstrict-overflow.
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 22 Nov 2007 10:40:45 +0000 (10:40 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 22 Nov 2007 10:40:45 +0000 (10:40 +0000)
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
tools/libxc/xc_core.c
tools/libxc/xc_core_x86.c

index 021d069c1cdcea26f7d5b8d032d03fc06b24d785..a4327101b67790b925305ee04fb6150bfaee9145 100644 (file)
@@ -107,17 +107,23 @@ xc_core_strtab_get(struct xc_core_strtab *strtab, const char *name)
     uint16_t ret = 0;
     uint16_t len = strlen(name) + 1;
 
+    if ( strtab->current > UINT16_MAX - len )
+    {
+        PERROR("too long string table");
+        errno = E2BIG;
+        return ret;
+    }
+    
     if ( strtab->current + len > strtab->max )
     {
         char *tmp;
-        if ( strtab->max * 2 < strtab->max )
+        if ( strtab->max > UINT16_MAX / 2 )
         {
             PERROR("too long string table");
             errno = ENOMEM;
             return ret;
         }
 
-
         tmp = realloc(strtab->strings, strtab->max * 2);
         if ( tmp == NULL )
         {
@@ -143,8 +149,8 @@ struct xc_core_section_headers {
 
     Elf64_Shdr  *shdrs;
 };
-#define SHDR_INIT       16
-#define SHDR_INC        4U
+#define SHDR_INIT       ((uint16_t)16)
+#define SHDR_INC        ((uint16_t)4)
 
 static struct xc_core_section_headers*
 xc_core_shdr_init(void)
@@ -180,7 +186,7 @@ xc_core_shdr_get(struct xc_core_section_headers *sheaders)
     if ( sheaders->num == sheaders->num_max )
     {
         Elf64_Shdr *shdrs;
-        if ( sheaders->num_max + SHDR_INC < sheaders->num_max )
+        if ( sheaders->num_max > UINT16_MAX - SHDR_INC )
         {
             errno = E2BIG;
             return NULL;
index fa92934ea65a8fc6c5b9c710facab57c26f421e1..d9eaa49b975816b7f4b2048c8e7ed876ec2450c8 100644 (file)
@@ -89,7 +89,7 @@ xc_core_arch_map_p2m(int xc_handle, xc_dominfo_t *info,
     }
 
     live_p2m_frame_list =
-        xc_map_foreign_batch(xc_handle, dom, PROT_READ,
+        xc_map_foreign_pages(xc_handle, dom, PROT_READ,
                              live_p2m_frame_list_list,
                              P2M_FLL_ENTRIES);
 
@@ -99,7 +99,7 @@ xc_core_arch_map_p2m(int xc_handle, xc_dominfo_t *info,
         goto out;
     }
 
-    *live_p2m = xc_map_foreign_batch(xc_handle, dom, PROT_READ,
+    *live_p2m = xc_map_foreign_pages(xc_handle, dom, PROT_READ,
                                     live_p2m_frame_list,
                                     P2M_FL_ENTRIES);