[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/9] Add API to manipulate dump_bitmap
From: |
Daniel P. Berrange |
Subject: |
Re: [Qemu-devel] [PATCH 1/9] Add API to manipulate dump_bitmap |
Date: |
Tue, 7 May 2013 17:23:52 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Tue, May 07, 2013 at 10:14:11AM -0600, Eric Blake wrote:
> On 05/07/2013 01:16 AM, Qiao Nuohan wrote:
> > Struct dump_bitmap is associated with a tmp file, and the tmp file can be
> > used
> > to save data of bitmap in kdump-compressed format temporarily.
> > The following patch will use these functions to get the data of bitmap and
> > cache
> > them into tmp files.
> >
> > Signed-off-by: Qiao Nuohan <address@hidden>
> > Reviewed-by: Zhang Xiaohe <address@hidden>
> > ---
>
> > + db->file_name = (char *)g_malloc(strlen(filename) + strlen(tmpname) +
> > 1);
> > +
> > + strcpy(db->file_name, tmpname);
> > + strcat(db->file_name, "/");
> > + strcat(db->file_name, filename);
>
> Off-by-one buffer overflow, since you forgot space for the NUL byte. We
> use C, not C++, so you don't need to cast the result of g_malloc().
Using g_strdup_printf("%s/%s", tmpname, filename); avoids the
allocation size problems entirely.
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
- [Qemu-devel] [PATCH 6/9] Add API to create page, (continued)
- [Qemu-devel] [PATCH 6/9] Add API to create page, Qiao Nuohan, 2013/05/07
- [Qemu-devel] [PATCH 8/9] Add API to write header, bitmap and page into vmcore, Qiao Nuohan, 2013/05/07
- [Qemu-devel] [PATCH 9/9] Make monitor command 'dump-guest-memory' dump in kdump-compressed format, Qiao Nuohan, 2013/05/07
- [Qemu-devel] [PATCH 7/9] Add API to free buf used by creating header, bitmap and page, Qiao Nuohan, 2013/05/07
- [Qemu-devel] [PATCH 3/9] Move include and struct definition to dump.h, Qiao Nuohan, 2013/05/07
- [Qemu-devel] [PATCH 2/9] Add API to manipulate cache_data, Qiao Nuohan, 2013/05/07
- [Qemu-devel] [PATCH 1/9] Add API to manipulate dump_bitmap, Qiao Nuohan, 2013/05/07
- [Qemu-devel] [PATCH 5/9] Add API to create data of dump bitmap, Qiao Nuohan, 2013/05/07
- Re: [Qemu-devel] [PATCH 0/9] Make monitor command 'dump-guest-memory' dump in kdump-compressed format, HATAYAMA Daisuke, 2013/05/08