Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ library and PHP PECL #1

Open
Qubitium opened this issue Dec 27, 2011 · 2 comments
Open

C++ library and PHP PECL #1

Qubitium opened this issue Dec 27, 2011 · 2 comments

Comments

@Qubitium
Copy link

Could not find an email address to contact "gtoubassi" so leaving a note here.

  1. The wiki mentions its in use in production at a PHP site but there is no PHP module. Is this built but not released?

  2. I'm not a C/C++ programmer and tried to tackle creating a PHP PECL extension but ran into the following problems:

A) The C++ library has no error checking or exception handling for all error cases.
B) Throws error on invalid model file (passing a non-existing file). This was fixed by checking file.good().
C) Throws error on broken model file (passing a file but not a valid model). I could not catch the error in C++ using try/catch so not sure what's going on. Again, I have little experience in C++.
D) Throws error on decompression of a string that is not a valid femtozip compressed string.

My half-baked PHP PECL module works only in a perfect environment where everything passed to it is perfect but would like the ability to handle real-world usage where bad data is throw at it and be able to recover and not crash due to errors.

Would love to have femtozip working in production and need some assistance.

@gtoubassi
Copy link
Owner

Thanks for the interest in femtozip. You are correct there is no publicly available php module for femtozip. Thanks for reporting these issues. In response to the specific issues:

  1. Passing non existent file: You are correct, this should be handled gracefully by femtozip. I will fix this.
  2. Passing existing but invalid file: I was thinking of adding a 4 byte header to model files ('fzip') followed by a model file version number. I will add this.
  3. Decompressing an invalid string: This is a bit trickier. Right now the code is designed for speed so there is a lack of range checking etc during the inner decompression loops. The idea was that client code would be responsible for knowing whether a payload should be decompressed. I don't want to add a header to each compressed payload as a way to check because that may add significant overhead to the final output (given that femtozip is targeted at small payloads, adding even 2 bytes of header is undesirable).

Can you provide some color on scenarios where you expect (3) above to occur? Thanks!

gtoubassi added a commit that referenced this issue Dec 28, 2011
1. Throw runtime_errors consistently rather than bare char *.
2. At the C api level, fz_load_model swallows runtime_error and returns null.  Is this the right thing?
3. Attempt to handle bad streams when reading a model.
@luvfilpus
Copy link

Is there a fork containing the pecl changes? I don't want to reinvent the wheel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants