added 3 changesets to branch 'refs/remotes/HaikuPM-github/package-management' old head: 118028674c77ec4ba5725a097dfbc9fd99b181b8 new head: b23d504796788536d66b523a2b5a3359691b3b2b overview: https://github.com/haiku/HaikuPM/compare/1180286...b23d504 ---------------------------------------------------------------------------- d055934: QueryParser: Fix some debug macros 10e9f49: QueryParser: Equation::Match(): Fix generic attribute case Init size to the buffer size before passing it to QueryPolicy::NodeGetAttribute(). Since size was 0 by default, we would only read 0 length data. b23d504: packagefs: UnpackingAttributeCookie: Open package ... when reading non-inline attribute data. Generally the package should already have been opened by the PackageNode owning the attribute (in InitVFS()), but that isn't the case for queries, which can read attributes from entirely unsuspecting nodes. Together with the QueryParser fix that should fix queries involving non-indexed attributes. [ Ingo Weinhold <ingo_weinhold@xxxxxx> ] ---------------------------------------------------------------------------- 2 files changed, 14 insertions(+), 6 deletions(-) headers/private/file_systems/QueryParser.h | 12 +++++++----- .../packagefs/nodes/UnpackingAttributeCookie.cpp | 8 +++++++- ############################################################################ Commit: d055934e36da802abd3958d0e7172bd5d666240a Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Sat Jun 1 00:40:08 2013 UTC QueryParser: Fix some debug macros ---------------------------------------------------------------------------- diff --git a/headers/private/file_systems/QueryParser.h b/headers/private/file_systems/QueryParser.h index beb6f70..083e7be 100644 --- a/headers/private/file_systems/QueryParser.h +++ b/headers/private/file_systems/QueryParser.h @@ -1108,7 +1108,7 @@ template<typename QueryPolicy> void Operator<QueryPolicy>::PrintToStream() { - D(__out("( ")); + QUERY_D(__out("( ")); if (fLeft != NULL) fLeft->PrintToStream(); @@ -1118,12 +1118,12 @@ Operator<QueryPolicy>::PrintToStream() case OP_AND: op = "AND"; break; default: op = "?"; break; } - D(__out(" %s ", op)); + QUERY_D(__out(" %s ", op)); if (fRight != NULL) fRight->PrintToStream(); - D(__out(" )")); + QUERY_D(__out(" )")); } @@ -1140,7 +1140,7 @@ Equation<QueryPolicy>::PrintToStream() case OP_LESS_THAN: symbol = "<"; break; case OP_LESS_THAN_OR_EQUAL: symbol = "<="; break; } - D(__out("[\"%s\" %s \"%s\"]", fAttribute, symbol, fString)); + QUERY_D(__out("[\"%s\" %s \"%s\"]", fAttribute, symbol, fString)); } #endif // DEBUG_QUERY @@ -1162,7 +1162,7 @@ Expression<QueryPolicy>::Expression(char* expr) } QUERY_D(if (fTerm != NULL) { fTerm->PrintToStream(); - D(__out("\n")); + QUERY_D(__out("\n")); if (*expr != '\0') PRINT(("Unexpected end of string: \"%s\"!\n", expr)); }); ############################################################################ Commit: 10e9f49914cc9e447f8248126c28fa2bf08e9f3a Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Sat Jun 1 01:58:11 2013 UTC QueryParser: Equation::Match(): Fix generic attribute case Init size to the buffer size before passing it to QueryPolicy::NodeGetAttribute(). Since size was 0 by default, we would only read 0 length data. ---------------------------------------------------------------------------- diff --git a/headers/private/file_systems/QueryParser.h b/headers/private/file_systems/QueryParser.h index 083e7be..b476efb 100644 --- a/headers/private/file_systems/QueryParser.h +++ b/headers/private/file_systems/QueryParser.h @@ -708,6 +708,7 @@ Equation<QueryPolicy>::Match(Entry* entry, Node* node, // get a pointer to the attribute in question union value<QueryPolicy> value; uint8* buffer = (uint8*)&value; + const size_t bufferSize = sizeof(value); // first, check if we are matching for a live query and use that value if (attributeName != NULL && !strcmp(fAttribute, attributeName)) { @@ -737,6 +738,7 @@ Equation<QueryPolicy>::Match(Entry* entry, Node* node, type = B_INT32_TYPE; } else { // then for attributes + size = bufferSize; if (QueryPolicy::NodeGetAttribute(node, fAttribute, buffer, &size, &type) != B_OK) { return MatchEmptyString(); ############################################################################ Commit: b23d504796788536d66b523a2b5a3359691b3b2b Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Sat Jun 1 02:04:25 2013 UTC packagefs: UnpackingAttributeCookie: Open package ... when reading non-inline attribute data. Generally the package should already have been opened by the PackageNode owning the attribute (in InitVFS()), but that isn't the case for queries, which can read attributes from entirely unsuspecting nodes. Together with the QueryParser fix that should fix queries involving non-indexed attributes. ---------------------------------------------------------------------------- diff --git a/src/add-ons/kernel/file_systems/packagefs/nodes/UnpackingAttributeCookie.cpp b/src/add-ons/kernel/file_systems/packagefs/nodes/UnpackingAttributeCookie.cpp index 867380f..e7488d6 100644 --- a/src/add-ons/kernel/file_systems/packagefs/nodes/UnpackingAttributeCookie.cpp +++ b/src/add-ons/kernel/file_systems/packagefs/nodes/UnpackingAttributeCookie.cpp @@ -128,8 +128,14 @@ UnpackingAttributeCookie::ReadAttribute(PackageNode* packageNode, return read_package_data(data, &dataReader, offset, buffer, bufferSize); } - // data not inline -- let the package create a data reader for us + // data not inline -- open the package and let it create a data reader for + // us Package* package = packageNode->GetPackage(); + int fd = package->Open(); + if (fd < 0) + RETURN_ERROR(fd); + PackageCloser packageCloser(package); + BAbstractBufferedDataReader* reader; status_t error = package->CreateDataReader(data, reader); if (error != B_OK)