xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] libxl: Fix uninitialized pointer when passing an empty cdrom
@ 2016-04-06 11:34 George Dunlap
  2016-04-06 12:10 ` Andrew Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: George Dunlap @ 2016-04-06 11:34 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Wei Liu, George Dunlap, Andrew Cooper

Commit 3fec17d4bb56567d139d7806392f4d8702d3f6a7 introduced a bug where
an empty cdrom would cause target_path to be uninitialized.  Initialize
target_path to NULL instead.

The other option here would have been to set target_path to NULL only
on the LIBXL_DISK_FORMAT_EMPTY path.  That would potentially enable
the compiler to catch future uninitialized paths, rather than having
those paths (potentially) dereference a NULL pointer.  But given that
a bunch of our compilers failed to catch *this* uninitialized path,
setting it to NULL at declaration seems the safer option for now.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
---
CC: Ian Jackson <ian.jackson@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
---
 tools/libxl/libxl_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 5b79aa2..eac5501 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1307,7 +1307,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
                 libxl__device_disk_dev_number(disks[i].vdev, &disk, &part);
             const char *format;
             char *drive;
-            const char *target_path;
+            const char *target_path = NULL;
             int colo_mode;
 
             if (dev_number == -1) {
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] libxl: Fix uninitialized pointer when passing an empty cdrom
  2016-04-06 11:34 [PATCH 1/1] libxl: Fix uninitialized pointer when passing an empty cdrom George Dunlap
@ 2016-04-06 12:10 ` Andrew Cooper
  2016-04-06 13:47   ` Ian Jackson
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cooper @ 2016-04-06 12:10 UTC (permalink / raw)
  To: George Dunlap, xen-devel; +Cc: Ian Jackson, Wei Liu

On 06/04/16 12:34, George Dunlap wrote:
> Commit 3fec17d4bb56567d139d7806392f4d8702d3f6a7 introduced a bug where
> an empty cdrom would cause target_path to be uninitialized.  Initialize
> target_path to NULL instead.
>
> The other option here would have been to set target_path to NULL only
> on the LIBXL_DISK_FORMAT_EMPTY path.  That would potentially enable
> the compiler to catch future uninitialized paths, rather than having
> those paths (potentially) dereference a NULL pointer.  But given that
> a bunch of our compilers failed to catch *this* uninitialized path,
> setting it to NULL at declaration seems the safer option for now.
>
> Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: George Dunlap <george.dunlap@citrix.com>

This looks like it will work.  Reviewed-by: Andrew Cooper
<andrew.cooper3@citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] libxl: Fix uninitialized pointer when passing an empty cdrom
  2016-04-06 12:10 ` Andrew Cooper
@ 2016-04-06 13:47   ` Ian Jackson
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Jackson @ 2016-04-06 13:47 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Wei Liu, George Dunlap, xen-devel

Andrew Cooper writes ("Re: [PATCH 1/1] libxl: Fix uninitialized pointer when passing an empty cdrom"):
> On 06/04/16 12:34, George Dunlap wrote:
> > Commit 3fec17d4bb56567d139d7806392f4d8702d3f6a7 introduced a bug where
> > an empty cdrom would cause target_path to be uninitialized.  Initialize
> > target_path to NULL instead.
> >
> > The other option here would have been to set target_path to NULL only
> > on the LIBXL_DISK_FORMAT_EMPTY path.  That would potentially enable
> > the compiler to catch future uninitialized paths, rather than having
> > those paths (potentially) dereference a NULL pointer.  But given that
> > a bunch of our compilers failed to catch *this* uninitialized path,
> > setting it to NULL at declaration seems the safer option for now.

This reasoning is plausible.

> > Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
> > Signed-off-by: George Dunlap <george.dunlap@citrix.com>
> 
> This looks like it will work.  Reviewed-by: Andrew Cooper
> <andrew.cooper3@citrix.com>

Thanks.  Queued.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-06 13:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-06 11:34 [PATCH 1/1] libxl: Fix uninitialized pointer when passing an empty cdrom George Dunlap
2016-04-06 12:10 ` Andrew Cooper
2016-04-06 13:47   ` Ian Jackson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).