libyal / libesedb

Library and tools to access the Extensible Storage Engine (ESE) Database File (EDB) format.
GNU Lesser General Public License v3.0
338 stars 91 forks source link

libesedb_file_get_table_by_utf[8,16]_name returns undocumented values #64

Closed sunsetkookaburra closed 1 year ago

sunsetkookaburra commented 1 year ago

Hello,

There is an edge case (either in documentation or logic) in libesedb_file_get_table_by_utf8_name and libesedb_catalog_get_table_definition_by_utf8_name that was discovered in https://github.com/sunsetkookaburra/rust-libesedb/issues/11.

According to the doc comments, only -1, 0 or 1 is returned; however, I observed 2 (LIBUNA_COMPARE_GREATER) being returned. It is filtering up from the string comparison in libesedb_catalog_definition_compare_name_with_utf8_string and libuna_utf8_string_compare_with_byte_stream.

It might also be helpful to call libcerror_error_set() for the other return values with a string explaining the table name couldn't be found. When I didn't see expected results, the first place I went looking for a cause was the error pointer passed in to libesedb_file_get_table_by_utf8_name, but of course it wasn't set and remained NULL.

Thanks for your hard work and commitment over the years to this library.

- Oli

joachimmetz commented 1 year ago

thx for flagging, I'll have a look as soon as time permits

joachimmetz commented 1 year ago

It might also be helpful to call libcerror_error_set() for the other return values with a string explaining the table name couldn't be found.

The libesedb_file_get_table_by_utf8_name function is not intended to error when the table does not exist. This is what the return value of 0 is for, not finding the name is not considered an error condition for this function.

According to the doc comments, only -1, 0 or 1 is returned; however, I observed 2 (LIBUNA_COMPARE_GREATER) being returned. It is filtering up from the string comparison in libesedb_catalog_definition_compare_name_with_utf8_string and libuna_utf8_string_compare_with_byte_stream.

Confirmed looks like the result is not set to 0 when the table was not found.

joachimmetz commented 1 year ago

Changes in https://github.com/libyal/libesedb/commit/90f1b7f5ecffe2b04015a5b92b4e223871ef57ac