summaryrefslogtreecommitdiff
path: root/rpmio
AgeCommit message (Collapse)AuthorFilesLines
2012-12-04Handle allocation failure in NSS DSA signature initializationPanu Matilainen1-2/+4
(cherry picked from commit 2d39f13064f6e6ff1a1633b708e7ba5622a7e8eb)
2012-12-04Fix build with older NSS versions that dont support SHA224Panu Matilainen1-0/+4
- SHA224-support was added around NSS 3.13, dont break compilation with older versions just for this rarely used hash. - HASH_AlgSHA224 is an enum so test for SHA224_LENGTH define instead (cherry picked from commit e15e29823451663e27a5bec6c865b37901f1c315)
2012-12-04Condence NSS getHashType() a bit, handle SHA224 tooPanu Matilainen1-24/+8
- Not much point in enumurating unsupported cases, or with switch-breaks after returns. - Recognize SHA224 too (cherry picked from commit 466a6b554e7f7ded9f1c59646e6b64243ce16812)
2012-11-30Get rid of long since deprecated VFY_VerifyDigest() usesPanu Matilainen1-29/+27
- VFY_VerifyDigest() has been deprecated since NSS >= 3.12 and for a good reason too: with VFY_VerifyDigest() caller needs to painfully enumerate every possible supported enc + hash combination, only for NSS to revert the process. Use the saner VFY_VerifyDigestDirect() interface instead and test for its presence in configure. - This means we now require NSS >= 3.12 but as that's already 4.5 years old and included in ancient beasts like RHEL-4, this doesn't seem exactly unreasonable requirement. And then there's always beecrypt... (cherry picked from commit 9b995a7674adba08248fac79ae8b23ecbecc13de)
2012-11-30Use NSS-defined constants for DSA q-bits and signature length tooPanu Matilainen1-3/+9
- No functional changes here (either), but using the proper constants simply makes things that little bit clearer. (cherry picked from commit 604da18bc267f89568081c1ab163c7fc45207220)
2012-11-30Avoid deprecation warnings from NSS >= 3.14Panu Matilainen1-6/+8
- NSS >= 3.14 introduces support for DSA2 and marks DSA_SUBPRIME_LEN as deprecated. Use explicit DSA1_SUBPRIME_LEN (we only support DSA1 for now) instead where available, add compatibility define for older versions. - Also directly include <blapit.h> where its defined - blabit.h gets included via cryptohi.h but being explicit about it avoids having to redefine it again "just in case". (cherry picked from commit 73be0fc7d9faab9f1120e2979f2ca1feed522195)
2012-11-05Fix strncat() boundaries in Fdopen()Dominique Leuenberger1-3/+3
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2012-11-05Update library current + age (ie libs are now 3.1.0)Panu Matilainen1-1/+1
- We haven't removed or changed any interfaces in a way that would require full soname bump, only a handful of new interfaces have been added. - There aren't actually any new interfaces in librpmbuild or librpmsign but for sanity and consistency's sake they're all updated...
2012-11-01Enable built-in %dirname macroPanu Matilainen1-3/+1
- This might've clashed with %dir in spec %files at some point as indicated by the comments, but that should no longer be the case.
2012-10-31Use private NSS context if NSS supports it (RhBug:871485)Panu Matilainen1-1/+23
- Older NSS versions operate on global context, which can cause all sorts of trouble when an API user tries to use NSS for their own purposes: eg they might want to use NSS databases which is not possible once we've initialized NSS with NSS_NoDB_Init(). Further background on the subject at https://wiki.mozilla.org/NSS_Library_Init - Use private private NSS context when possible (NSS >= 3.12.5) to avoid such clashes, but keep support for older versions for now.
2012-10-30Handle EINTR in Fread() and Fwrite()Panu Matilainen1-2/+6
- Not all systems automatically restart signal-interrupted operations, handle this centrally since its so easy to do. Also related to RhBug:580974.
2012-10-19Eliminate copy-paste nibble(), use rnibble() insteadPanu Matilainen1-12/+1
2012-10-19Add support for beecrypt as an alternative crypto implementationMichael Schroeder2-0/+542
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2012-10-11Missing include in string poolPanu Matilainen1-0/+1
- When compiled without selinux support, stdlib.h doesn't get included here. Wtf?
2012-10-09Add lua 5.2 support.Anders F Bjorklund1-7/+33
Add compatibility support for both lua-5.1 and lua-5.2, assuming that the LUA_COMPAT might have been disabled. Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2012-09-28Make string pool strings static in memoryFlorian Festi1-33/+56
- Use multiple chunks that get allocated as old ones get filled up instead of reallocating, store direct pointers to the strings in the id array. - This prevents nasty surprises when previously retrieved pointer to a pool string goes invalid underneath us due to somebody adding a new string, and restores former rpm API behavior: string pointers retrieved from eg rpmds and rpmfi are valid for the entire lifetime of those objects.
2012-09-27Add doxygen documentation to string pool APIPanu Matilainen1-13/+79
2012-09-27Fixup string pool prototype argument names to match implementationPanu Matilainen1-7/+7
- Just a simple s/sidpool/pool/ to match the implementation, "sidpool" is a leftover from early draft version that somehow made its way to the master tree.
2012-09-26Add function to get number of unique strings in the poolPanu Matilainen2-0/+8
2012-09-19Change poolHash to use internal collision resolutionFlorian Festi1-70/+60
2012-09-19Aargh, stupid thinko in rpmstrPoolStrlen() last id special casePanu Matilainen1-1/+1
- At the largest id, the end boundary is data, not offset size... doh
2012-09-18Make pool string->id operations properly length-awarePanu Matilainen1-19/+41
- Allow looking up and inserting partial key strings, this is useful in various cases where previously a local copy was needed for \0-terminating the key in the caller. - Take advantage of rstrlenhash() in rpmstrPoolId(), previously the length was only interesting when adding so we wasted a strlen() on every call when the string was already in the pool.
2012-09-18Add length aware variant(s) of string hashingPanu Matilainen1-0/+27
- Being able to hash partial strings is needed for allowing string pool to operate on partial strings...
2012-09-18Enhanced string hash to permit calculating string length on the same callPanu Matilainen2-17/+28
- String hashing needs to walk the entire string anyhow, might as well take advantage of this and have it return the string length to avoid having to separately call strlen() in the cases where this matters. - Move the implementation into rpmstrpool.c for inlining possibilities, rstrhash() is now just a wrapper to rstrlenhash(). The generic hash implementation could not take advantage of this anyway really.
2012-09-18Dont assume \0 terminated strings in rpmstrPoolPut()Panu Matilainen1-2/+3
- Before this, the slen argument was only good for avoiding an extra strlen() but being able to handle shove and lookup partial strings without local copy+modify in callers is handy, this is one of the prerequisites for that.
2012-09-17Use pool id's for hash table key, lookup strings from pool as neededPanu Matilainen1-23/+19
- The pool itself can address its contents by id alone, storing pointers to the strings only hurts as reallocation moving the data blob requires rehashing the whole thing needlessly. - We now store just the key id in the hash buckets, and lookup the actual string for comparison from the pool. This avoids the need to rehash on realloc and saves memory too, and this is one of the biggest reasons for wanting a separate hash implementation for the string pool. Incidentally, this is how libsolv does it too. - Individual bucket allocation becomes rather wasteful now: a bucket stores a single integer, and a single pointer to the next bucket, a pointer which can be twice the size of the key data it holds. Further tuning and cleaning up after the marriage of these two datatypes left after the honeymoon is over...
2012-09-17Move the string pool struct definition earlier so we can reference it...Panu Matilainen1-12/+12
2012-09-17Inline poolHashfindEntry() into GetEntry(), nothing else needs itPanu Matilainen1-13/+5
2012-09-17Eliminate key comparison and hash function vectors from poolHashPanu Matilainen1-20/+7
- As the pool is hardwired to single hash type, these dont make any sense here and the extra indirection will only hurt performance.
2012-09-17More poolHash multiple data-value cleanupsPanu Matilainen1-13/+7
- The only data associated with a pool key is a single id, we dont need an array for that - Change poolHash get-entry return the id directly instead of pointer array
2012-09-17Eliminate redundant data counting from poolHashPanu Matilainen1-25/+6
- There's a strict 1:1 relation between keys and data in the string pool, this keeping count of data is pointless.
2012-09-17Eliminate unnecessary key and data free-functionality from poolHashPanu Matilainen1-20/+2
2012-09-17Pull a private hash-implementation copy to string poolPanu Matilainen1-9/+213
- The string pool is more specialized a data structure to be efficiently handled with the generic hash table implementation in rpmhash.[CH] and really requires quite a different approach. - For starters, import a private copy generated roughly with: gcc -E -DHASHTYPE=poolHash \ -DHTKEYTYPE="const char *" -DHTDATATYPE=rpmsid rpmhash.C ...and clean it up a bit: eliminate unused functions (except for stats which we'll want to keep for debug purposes), make remaining functions static and overall tidy up from the mess 'gcc -E' created. Lots of redundant fluff here still, to be cleaned up gradually... - This doesn't change anything at all, but opens up the playground for tuning the pool hash implementation in ways the generic version could not (at least sanely) be.
2012-09-17Rename string pool hash type to poolHashPanu Matilainen1-10/+10
- No changes other than a rename for next steps...
2012-09-15Lift string pool rehash into a separate helper functionPanu Matilainen1-10/+20
- This way we have exactly one place for controlling hash (re)creation size strategies etc.
2012-09-15Use a saner pool hash resize hintPanu Matilainen1-1/+1
- The previous size hint would actually cause us to shrink the hash bucket allocation, requiring the hash to resize itself immediately afterwards. As if the rehashes weren't expensive enough already...
2012-09-13Add a string equality check function to string pool APIPanu Matilainen2-0/+13
- As a special case, two strings (ids) from the same pool can be tested for equality in constant time (integer comparison). If the pools differ, a regular string comparison is needed.
2012-09-12Only rehash the pool on insert if the data area actually movedPanu Matilainen1-2/+3
- realloc() might not need to actually move the data, and when it doesn't we dont need to do the very expensive rehash either. Unsurprisingly makes things a whole lot faster.
2012-09-12Allow keeping hash table around on pool freeze, adjust callersPanu Matilainen2-18/+29
- Pool id -> string always works with a frozen pool, but in some cases we'll need to go the other way, allow caller to specify whether string -> id lookups should be possible on frozen pool. - On glibc, realloc() to smaller size doesn't move the data but on other platforms (including valgrind) it can and does move, which would require a full rehash. For now, just leave all the data alone unless we're also freeing the hash, the memory savings isn't much for a global pool (which is where this matters)
2012-09-12String pool id 0 equals NULLPanu Matilainen1-1/+1
- Pool id 0 is special case for "not found". Return an actual NULL instead of an empty string.
2012-09-12Avoid doing anything if pool is already frozenPanu Matilainen1-1/+1
2012-09-11Fix segfault on rpmstrPoolId() on frozen poolPanu Matilainen1-2/+2
- String -> id lookups need the hash table in place even if we're not adding. We could do a linear search in such a case but...
2012-09-11Make rpmstrPoolUnfreeze() safe to call on unfrozen poolPanu Matilainen1-1/+1
2012-09-09And now, on to the embarrassing string-pool reimplementation bugs, take IPanu Matilainen1-4/+14
- String pool offset resize was off by one, oops - String pool data-area resize requires rehashing all the strings, as the key pointers change. Ouch. Should be avoidable by extending rpmhash to allow passing the pool itself around in comparisons as "self" and using offsets as keys, but for now working counts more than speed. - The unfreeze-sizehint calculation could be negative. Turn the initial size into constant and use that as a minimum, otherwise rehashing uses (more or less arbitrary) heuristics to come up with some number. Lots of fine-tuning ahead...
2012-09-07Move string pool typedefs to rpmtypes.hPanu Matilainen1-2/+1
- I suspect these will be used widely, to avoid having to include rpmstrpool.h all over in headers...
2012-09-07First cut of a libsolv-style string <-> id pool APIPanu Matilainen3-1/+198
- The pool stores "arbitrary" number of strings in a space-efficient manner, with near constant (hashed) string -> id lookup/store and constant time id -> string and id -> string length lookups. - Credits for the idea go to the Suse developers working on libsolv, the basic concept is directly lifted from there but details differ due to using rpm's own hash table implementation etc. Another minor difference is using size_t for offsets to permit over 4GB total data size on 64bit systems, the total number of id's in the pool is limited to uint32 max however (like in libsolv). - Any (re)implementation bugs by yours truly, this is almost certainly going to need further tuning and tweaking, API and otherwise.
2012-09-03Minor optimization to rnibble()Panu Matilainen1-2/+2
- Check for lowercase letters before uppercase. A very minor difference as such, but our file digests use lowercase hex and this gets called a lot from rpmfiNew().
2012-08-17Revert "Always return NULL from fdFree()"Panu Matilainen1-1/+1
- This reverts commit 4c1f7e335de1724661ce63c53186d161ab71a63f: various things inside and outside of rpm actually do still depend on the old behavior, and leak file descriptors otherwise. As an easy backportable band-aid, revert back to the previous behavior, to which various callers are tuned to fix the regression introduced in rpm 4.10.0. The real fix would be something more like "eliminate fdFree() and make Fclose() honor refcounts".
2012-07-02Dont use mmap() for anything, axe the code insteadPanu Matilainen1-38/+0
- Commit 4cb02aa928d3e41f636d0e01356c7a3cb51018ee asked to see what breaks when mmap() is used, now we know: large package support broke when enabling it. Could be fixed of course by eg adding a size cap to the fsm part as well, but just doesn't seem worth it: I fail to measure any meaningful performance improvement from mmap usage in either case, and added complexity for what is close to zero benefit just doesn't make sense... and various sources in fact note the rpm usage (read through the entire file sequentially) as one of the cases where mmap() is NOT beneficial due to mmap() high setup + teardown cost + page fault speed (or lack of thereof).
2012-05-31Only use local mempcpy() if system libraries dont provide onePanu Matilainen1-0/+2
- Obvious yes, but how come this didn't barf on my other rather identical system? Meh.