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-devel

RE: [Xen-devel] [PATCH] gcc4isms part 2

To: <xen-devel@xxxxxxxxxxxxxxxxxxxxx>
Subject: RE: [Xen-devel] [PATCH] gcc4isms part 2
From: "Cihula, Joseph" <joseph.cihula@xxxxxxxxx>
Date: Tue, 8 Mar 2005 08:01:01 -0800
Cc: "Rik van Riel" <riel@xxxxxxxxxx>
Delivery-date: Tue, 08 Mar 2005 16:02:52 +0000
Envelope-to: xen+James.Bulpin@xxxxxxxxxxxx
List-archive: <http://sourceforge.net/mailarchive/forum.php?forum=xen-devel>
List-help: <mailto:xen-devel-request@lists.sourceforge.net?subject=help>
List-id: List for Xen developers <xen-devel.lists.sourceforge.net>
List-post: <mailto:xen-devel@lists.sourceforge.net>
List-subscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=subscribe>
List-unsubscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=unsubscribe>
Sender: xen-devel-admin@xxxxxxxxxxxxxxxxxxxxx
Thread-index: AcUhCPXGxX6zRx57QdqEA1Dg72hTCAABhsmA
Thread-topic: [Xen-devel] [PATCH] gcc4isms part 2
Rik van Riel wrote:
> This completes the gcc4ism changes to the Xen tree.  All of
> the changes in this patch are in the tools/ subdirectory and
> are pretty simple.  Some of the changes are for overly strict
> gcc4 warnings, but I guess it's still good to verify that the
> variable really wasn't unused, or that the sign change is
> really harmless.
> 
...
> --- xen-unstable/tools/xfrd/lzi_stream.c.gcc4 2005-03-04
> 16:18:17.000000000 -0500 +++
> xen-unstable/tools/xfrd/lzi_stream.c  2005-03-04 16:19:36.000000000
>      -0500 @@ -242,7 +242,7 @@ int err = 0, k = 0;
>      //dprintf(">\n");
>      if(s->eof) goto exit;
> -    err = unmarshal_uint32(s->io, &k);
> +    err = unmarshal_uint32(s->io, (unsigned int *)&k);
>      if(err) goto exit;
>      if(k > s->inbuf_size){
>          err = -EINVAL;

While the compiler will promote k to an unsigned for the test against
s->inbuf_size a few lines later and thus there is not a buffer overflow
here... there is really no good reason for k not to be declared
unsigned.  I'd propose instead:

--- xeno-unstable/tools/xfrd/lzi_stream.c       2005-03-04
18:13:13.052620912 -0800
+++ xeno-unstable-patch/tools/xfrd/lzi_stream.c 2005-03-04
17:37:00.019972088 -0800
@@ -239,7 +239,8 @@ LZIState * LZIState_new(IOStream *io, in
 }
 
 int read_block(LZIState *s){
-    int err = 0, k = 0;
+    int err = 0;
+    uint32_t k = 0;
     //dprintf(">\n");
     if(s->eof) goto exit;
     err = unmarshal_uint32(s->io, &k);


> --- xen-unstable/tools/xfrd/marshal.c.gcc4    2005-03-04
> 16:23:31.000000000 -0500 +++
> xen-unstable/tools/xfrd/marshal.c     2005-03-04 16:24:14.000000000
-0500
>  @@ -166,7 +166,7 @@ int unmarshal_string(IOStream *io, char *s,
>      uint32_t s_n){ int err = 0, val_n = 0;
>      //dprintf(">\n");
> -    err = unmarshal_uint32(io, &val_n);
> +    err = unmarshal_uint32(io, (unsigned int *)&val_n);
>      if(err) goto exit;
>      if(val_n >= s_n){
>          err = -EINVAL;
> @@ -184,7 +184,7 @@
>      int err = 0, val_n = 0;
>      char *val = NULL;
>      //dprintf(">\n");
> -    err = unmarshal_uint32(io, &val_n);
> +    err = unmarshal_uint32(io, (unsigned int *)&val_n);
>      if(err) goto exit;
>      val = allocate(val_n + 1);
>      if(!val){

Ditto:

--- xeno-unstable/tools/xfrd/marshal.c  2005-03-04 18:13:13.291584584
-0800
+++ xeno-unstable-patch/tools/xfrd/marshal.c    2005-03-04
17:40:52.181678144 -0800
@@ -164,7 +164,8 @@ int marshal_string(IOStream *io, char *s
 }
 
 int unmarshal_string(IOStream *io, char *s, uint32_t s_n){
-    int err = 0, val_n = 0;
+    int err = 0;
+    uint32_t val_n = 0;
     //dprintf(">\n");
     err = unmarshal_uint32(io, &val_n);
     if(err) goto exit;
@@ -181,7 +182,8 @@ int unmarshal_string(IOStream *io, char 
 }
 
 int unmarshal_new_string(IOStream *io, char **s, uint32_t *s_n){
-    int err = 0, val_n = 0;
+    int err = 0;
+    uint32_t val_n = 0;
     char *val = NULL;
     //dprintf(">\n");
     err = unmarshal_uint32(io, &val_n);


Signed-off-by: Joseph Cihula <joseph.cihula@xxxxxxxxx>


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-devel

<Prev in Thread] Current Thread [Next in Thread>