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

OPDSParse with invalid data #874

Closed
BPerlakiH opened this issue Jul 20, 2024 · 2 comments · Fixed by #884
Closed

OPDSParse with invalid data #874

BPerlakiH opened this issue Jul 20, 2024 · 2 comments · Fixed by #884
Assignees
Labels
Milestone

Comments

@BPerlakiH
Copy link
Collaborator

Make sure that inputing invalid data into the OPDSParse function is handled correctly.

We already have a unit test case for this, but so far it has been disabled, with the comment:
"Requires work in dependency to resolve the issue."

As libkiwix is always returning true, regardless of the input, this might cause some issues, as invalid input handling is not in place.

On the reader side:

func parse(data: Data) throws {
if !self.__parseData(data) {
throw LibraryRefreshError.parse
}
}

Whereas underneath that we have:

- (BOOL)parseData:(nonnull NSData *)data {
try {
NSString *content = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
std::shared_ptr<kiwix::Manager> manager = std::make_shared<kiwix::Manager>(self.library);
return manager->readOpds([content cStringUsingEncoding:NSUTF8StringEncoding],
[@"https://library.kiwix.org" cStringUsingEncoding:NSUTF8StringEncoding]);
} catch (std::exception) {
return false;
}
}

Related libkiwix ticket: kiwix/libkiwix#1099

@BPerlakiH BPerlakiH linked a pull request Jul 20, 2024 that will close this issue
@BPerlakiH BPerlakiH self-assigned this Jul 20, 2024
@kelson42 kelson42 added this to the 3.5.0 milestone Jul 20, 2024
@kelson42 kelson42 added the bug label Jul 20, 2024
@kelson42
Copy link
Contributor

@BPerlakiH Please secure that whatever the libkiwix returns true or false, this is handled properly here and the app does not crash. For the rest, kiwix/libkiwix#1099 should be fixed.

@BPerlakiH
Copy link
Collaborator Author

Please, see the related PR here: #884,
securing no crashes on the reader side.

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