https://bugs.freedesktop.org/show_bug.cgi?id=56110

          Priority: medium
            Bug ID: 56110
          Assignee: [email protected]
           Summary: re-write stream operators to methods
          Severity: normal
    Classification: Unclassified
                OS: All
          Reporter: [email protected]
          Hardware: Other
            Status: UNCONFIRMED
           Version: 3.7.0.0.alpha0+ Master
         Component: Libreoffice
           Product: LibreOffice

The SvStream class exports a lot of operators for both reading and writing
values to binary files. We need to clean that up and create new methods eg.
'readInt32()' that return a defined default result - ie. zero for ints, false
for bools, "" for strings etc. ie. perhaps:

sal_Int32 readInt32(sal_Int32 nDefault = 0);

We should take care as we do the change to catch those (rather few) places
where the undefined result is used as a feature: ie. "if we failed to read, the
default was the old value of the result". ie. this sort of thing:

SvStream& SvStream::operator>>(sal_uInt16& r)
{
    sal_uInt16 n = 0;
    READNUMBER_WITHOUT_SWAP(sal_uInt16, n)
    if (good())
    {
        if (bSwap)
            SwapUShort(n);
        r = n;
    }
    return *this;
}

is really bad news for security auditing - and it'd be lovely to kill it
everywhere.

Similar changes for writing would also be great - again, to avoid casual
changes to types causing knock-on breakage in files.

It is possible that a magic CLANG plugin could auto-generate such a patch,
which may be worth investigating due to the many call-sites involved.

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to