[libvirt] [PATCH] S390: Fix virSysinfoRead memory corruption

Eric Blake eblake at redhat.com
Fri Dec 7 17:57:35 UTC 2012


On 12/07/2012 01:44 AM, Viktor Mihajlovski wrote:
> There was a double free issue caused by virSysinfoRead on s390,
> as the same manufacturer string instance was assigned to more
> than one processor record.
> Cleaned up other potential memory issues and restructured the sysinfo
> parsing code by moving repeating patterns into a helper function.
> 
> BTW: I hit an issue with using strchr(string,variable), as I am
> still compiling with gcc 4.4.x, see
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36513

I seem to recall that we've hit this before.

/me searches

Yep - src/util/buf.c contains this gem:

    while (*cur != 0) {
        /* strchr work-around for gcc 4.3 & 4.4 bug with -Wlogical-op
         * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36513
         */
        char needle[2] = { *cur, 0 };
        if (strstr(toescape, needle))
            *out++ = escape;
        *out++ = *cur;
        cur++;
    }


> I circumvented this using index(), which is deprecated, but working.

No.  Don't use index(), as it is not guaranteed to exist.

What we should _really_ do is provide a change in
m4/virt-compile-warnings.m4 that disables -Wlogical-op if compiling with
a broken gcc, now that newer gcc doesn't force its stupidity on a
sensible strchr() usage.  I'll attempt that patch independently, and
then your patch can go on top using strchr() from the get-go.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20121207/93bdf85f/attachment-0001.sig>


More information about the libvir-list mailing list