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

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

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;

> 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

Attachment: signature.asc
Description: OpenPGP digital signature

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