D20143: ora:kra: qstrcmp -> qstrncmp

Pino Toscano noreply at phabricator.kde.org
Sun Mar 31 17:02:04 BST 2019


pino added inline comments.

INLINE COMMENTS

> kra.cpp:22
> +static constexpr char s_magic[] = "application/x-krita";
> +static constexpr int s_magic_size = sizeof(s_magic);
> +

this also counts the null terminator (as it is part of the static string)

> kra.cpp:61
>      if (device->peek(buff, sizeof(buff)) == sizeof(buff))
> -        return qstrcmp(buff + 0x26, "application/x-krita") == 0;
> +        return qstrncmp(buff + 0x26, s_magic, s_magic_size) == 0;
>  

this can be memcmp even (slightly faster than str*cmp)

> ora.cpp:21
> +static constexpr char s_magic[] = "image/openraster";
> +static constexpr int s_magic_size = sizeof(s_magic);
> +

ditto

> ora.cpp:60
>      if (device->peek(buff, sizeof(buff)) == sizeof(buff))
> -        return qstrcmp(buff + 0x26, "image/openraster") == 0;
> +        return qstrncmp(buff + 0x26, s_magic, s_magic_size) == 0;
>  

ditto

REPOSITORY
  R287 KImageFormats

REVISION DETAIL
  https://phabricator.kde.org/D20143

To: aacid
Cc: pino, security-team, rempt, kde-frameworks-devel, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20190331/6bc45956/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list