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

Re: [libvirt] [PATCH 1/6] Introduce a set of APIs for managing architectures



On Tue, Dec 18, 2012 at 10:24:06AM +0100, Jiri Denemark wrote:
> On Tue, Dec 11, 2012 at 14:53:36 +0000, Daniel P. Berrange wrote:
> > +virArch virArchFromHost(void)
> > +{
> > +    struct utsname ut;
> > +    virArch arch;
> > +
> > +    uname(&ut);
> > +
> > +    /* Some special cases we need to handle first
> > +     * for non-canonical names */
> > +    if (ut.machine[0] == 'i' &&
> > +        ut.machine[2] == '8' &&
> > +        ut.machine[3] == '6' &&
> > +        ut.machine[4] == '\0') {
> > +        arch = VIR_ARCH_I686;
> 
> This could access undefined memory in the unlikely case of ut.machine
> being just "i". Insert the ut.machine[1] != '\0' test to match the
> original code in qemu_command.c.

I decided it is better just to add a  'strlen(ut.machine) == 4'
test as the first thing in the conditional


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


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