D8400: libzip: Improve test archive function

Elvis Angelaccio noreply at phabricator.kde.org
Sat Oct 21 16:56:25 UTC 2017


elvisangelaccio requested changes to this revision.
elvisangelaccio added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> CMakeLists.txt:18
>  
> +find_package(ZLIB)
> +set_package_properties(ZLIB PROPERTIES

Should be marked as `REQUIRED`

> CMakeLists.txt:22
> +                       DESCRIPTION "The Zlib compression library"
> +                       PURPOSE "Required for libzip plugin")
> +

"Required for integrity check in libzip plugin"

> libzipplugin.cpp:429
> +    // Check CRC-32 for each archive entry.
> +    int nofEntries = zip_get_num_entries(archive, 0);
> +    for (int i=0; i < nofEntries; i++) {

const

> libzipplugin.cpp:430
> +    int nofEntries = zip_get_num_entries(archive, 0);
> +    for (int i=0; i < nofEntries; i++) {
> +

spaces around =

> libzipplugin.cpp:440
> +        zip_file *zf = zip_fopen_index(archive, i, 0);
> +        uchar *buf = new uchar[sb.size];
> +        int len = zip_fread(zf, buf, sb.size);

leak if we go in either of the `return false` branches.

Use a scoped pointer, so that we can also drop the `delete buf` below.

> libzipplugin.cpp:441
> +        uchar *buf = new uchar[sb.size];
> +        int len = zip_fread(zf, buf, sb.size);
> +        if (len == -1 || uint(len) != sb.size) {

const

REPOSITORY
  R36 Ark

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

To: rthomsen, elvisangelaccio
Cc: kde-utils-devel, #ark, tctara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-utils-devel/attachments/20171021/4af02c76/attachment-0001.html>


More information about the Kde-utils-devel mailing list