Code Monkey home page Code Monkey logo

Comments (8)

0-wiz-0 avatar 0-wiz-0 commented on May 28, 2024

This is not a bug in libzip.
The archive comment for this archive is 1455 bytes. After the "signed by SignApk" part is a zero byte and then the other 1400+ bytes follow. If you just print them with printf, you won't see anything after the zero byte, but it's there.

from libzip.

elvisangelaccio avatar elvisangelaccio commented on May 28, 2024

Hmm, somehow I don't get the zero byte, and even

printf("%s\n", zip_get_archive_comment(archive, nullptr, ZIP_FL_ENC_GUESS));

does show the very same string I pasted in my first comment. Could it be a problem with my locale?

from libzip.

0-wiz-0 avatar 0-wiz-0 commented on May 28, 2024

printf stops writing when it encounters a zero byte (strings in C are zero-terminated).
You should pass a pointer to a variable instead of nullptr and look at the returned length to find out how big the comment is.

from libzip.

elvisangelaccio avatar elvisangelaccio commented on May 28, 2024

My point is I don't get the zero byte after the "signed by SignApk" sequence. The lenp argument says the comment is 2931 bytes long.

from libzip.

0-wiz-0 avatar 0-wiz-0 commented on May 28, 2024

So what does (untested, something like):

char *foo=zip_get_archive_comment(archive, nullptr, ZIP_FL_ENC_GUESS)
printf("%x\n", foo[strlen("signed by SignApk")]);

print?

from libzip.

elvisangelaccio avatar elvisangelaccio commented on May 28, 2024

That snippet prints ffffffe2.

I should probably mention that I'm using this code from a C++ program, not sure if related. I'll try again with a minimal test program in C.

from libzip.

0-wiz-0 avatar 0-wiz-0 commented on May 28, 2024

I'm sorry, you're right. I misunderstood.
There was a bug in libzip. CP437 '0' was not translated to UTF-8 '0'.
I've just pushed a commit that should fix this, please let me know if it fixes the problem for you.

from libzip.

elvisangelaccio avatar elvisangelaccio commented on May 28, 2024

Yes, the fix works for me. Thanks!

from libzip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.