summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2011-11-07Use pgpDigParamsAlgo() throughout the codebasePanu Matilainen4-13/+17
- Tedious but straightforward conversion to use the API instead of going to the struct directly. - Remove digest.h includes where no longer necessary
2011-11-07Eliminate direct pgpDig accesses from pubkey importingPanu Matilainen1-1/+2
2011-11-07Eliminate direct pgpDig access from package reading codePanu Matilainen1-3/+5
2011-11-07Eliminate direct pgpDig accesses from lowlevel signature codePanu Matilainen1-7/+11
2011-11-07Take advantage of parsePGPSig() in pgpsigFormat() tooPanu Matilainen2-6/+7
- Doesn't make for less lines in this case but unifying the accesses is good anyway.
2011-11-07Unify the parsePGP() variants from package.c and rpmchecksig.cPanu Matilainen3-38/+26
- Hide allocation inside the helper, automatically free on failure - Return pointer to the signature parameters on success to simplify life for callers - Don't bother checking or reporting the signature version: the pgp parser errors out if it encounters unsupported version and does not scrible anything to the version field in that case, mumbling about "V0 signatures" is not particularly helpful. - Log the bad package names from rpmpkgReadHeader() too
2011-11-07Hide pgpDig alloc etc details in the parsePGP helperPanu Matilainen1-21/+23
- Return a pointer to the signature part on success, hide allocation (and free on failure) in the helper. Makes life a little bit saner for the callers and limits the places where we access the full pgpDig further.
2011-11-07Add another pgpVerify variant which takes key and sig as separate argsPanu Matilainen1-1/+1
- pgpVerifySig() is now just a dumb wrapper around pgpVerifySignature() which does the real work. - Update the sole caller to use the new interface instead, deprecate the old dig interface. - First steps towards getting rig of pgpDig which always was a strange creature and now is nothing but a nuisance and obfuscation. Yes keys and signatures walk hand in hand much of the time, but they come from different sources and want to be handled as separate data really.
2011-11-07Eliminate couple of unnecessary pgpDig usagesPanu Matilainen2-6/+5
- stashKeyid() only wants the signature, not the whole dig - dig argument to readFile() was simply unused
2011-11-04Add a couple of missing includes, masked by NSS headersPanu Matilainen2-0/+3
2011-10-24Sanitize pgpsigFormat()Panu Matilainen1-36/+13
- Eliminate bogus size calculations: we have a buffer of td->count size that may or may not contain legal OpenPGP signature. Leave it up to pgpPrtPkts() to validate & figure it out and check its return code instead, eliminating need to repeat a bunch of tedious calculations here. - Use non-zero signature version is used as a hint for valid signature, should be "close enough" for the rest of the code.
2011-10-23Fix unterminated buffer after readlink() callThomas Jarosch1-2/+6
readlink() never terminates the buffer. Detected by "cppcheck" (git HEAD) Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com> Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2011-10-21Fix ancient off-by-one at end boundary in string array size calculationPanu Matilainen2-17/+19
- String array size calculation could read one byte past data end pointer when expected count and number of \0's disagree (ie invalid data) due to while condition side-effects + bounds checking being in the inner loop. - Lift the string length calculation to inline helper function, used for both string and string array types. - Streamline the calculations: - Eliminate unnecessary length increments, calculate the length from pointer distance - Eliminate end pointer NULL checking within the loop: when caller doesn't supply end pointer, cap to HEADER_MAX_DATA (ie 16MB), anything larger would trip up in later hdrchkData() checks anyway. - Avoid the off-by-one by eliminating the problematic inner loop.
2011-10-20Verify the entire region trailer, not just its offset, is within data areaPanu Matilainen3-5/+6
- Offset being within the data area doesn't help if the actual data doesn't fit. Since the trailer size is well known, we can just as easily make the check accurate to prevent reading beyond end of data in case the offset is subtly wrong. - In headerLoad(), region offset of zero doesn't need sanity checking, only validate if its something else and do so accurately there too.
2011-10-12Fix pretrans dependency calculation when provider is upgradedPanu Matilainen1-10/+17
- Pretrans-dependencies are twisty little beasts unlike anything else... When a pretrans-dependency provider is updated, the currently installed version is the provider for that transaction, unlike others where the packages from installing set act as providers for updates. So when looking up pretrans deps, we must not prune the to-be-erased packages from the db match iterators. As an added twist, we also must not cache these non-pruned cases as it would mess up the cache for "regular" dependencies. - Fixes this case reported on fedora-devel: http://lists.fedoraproject.org/pipermail/devel/2011-October/158058.html
2011-10-11build: Update .gitignore rulesMukund Sivaraman1-0/+1
2011-10-11Let headerLoad() failure message come throughPanu Matilainen1-1/+2
- headerVerify() always returns with a message even for OK results, which was masking the error message from headerLoad(), sometimes giving not very helpful "headerRead failed: Header sanity check OK" style messages.
2011-10-06Eliminate headerCheckPayloadFormat() from the APIPanu Matilainen3-37/+31
- While we're on API killing spree... Exporting this was needless and dumb to begin with (greetings to self in 2007...), bury it inside depends.c as static and let rot there. - Might be a better idea to kill it completely with some other mechanism such as turning payload format into rpmlib() dependency internally but just get it out of public sight for now.
2011-10-06Eliminate headerMergeLegacySigs() from the APIPanu Matilainen2-9/+6
- No need to export this in the API - if you want merged signature tags you use rpm's package reading functions.
2011-10-06Eliminate leftover headerRegenSigHeader() functionPanu Matilainen2-55/+0
- This was only ever used by repackage support inside rpm and has been orphan since 2008, likely more than just a little broken too as it doesn't know about 64bit types and all. RIP.
2011-10-06Only bother allocating a pgpDig when neededPanu Matilainen1-9/+3
- Now that rpmVerifySignature() doesn't require a non-null dig for digests, don't bother allocating one unless necessary. - pgpNewDig() cannot fail so dont bother checking.
2011-10-06Eliminate redundant NULL-checks in lower level sigchecking functionsPanu Matilainen1-9/+3
- sigtd->data and dig checking (where needed) is done at rpmVerifySignature() level, dont bother double-checking - Hash context is dup'ed, which CAN fail, so while we dont need to check the argument for non-null, the dup result needs to be checked for digests. For actual signatures the dup happens elsewhere, we dont need to check the argument for non-null here.
2011-10-06Sanitize rpmVerifySignature() a bitPanu Matilainen1-7/+13
- Hash context is required for everything, require non-NULL ctx in rpmVerifySignature() already - pgpDig is only relevant for true signature, digest checking doesn't need it - dont require dummy dig to be passed for digests. - Treat unknown signatures as a case of bad parameters: we're the only caller of rpmVerifySignature() so it'd be us screwing up if we ask for unknown signature to be verified. - Treat bad parameters as a hard failure instead of "not found", bad parameters mean we cannot verify the signature which really equals FAIL.
2011-10-05Split signature/digest verification out of headerVerify()Panu Matilainen1-114/+134
- headerVerify() is big enough without having all the signature goo inline, just lift the whole signature/digest business into separate function. Supposedly no functional changes...
2011-10-05Unobfuscate header digest calculation in headerVerify()Panu Matilainen1-18/+5
- Assigning goo to temporary variables for calling rpmDigestUpdate() doesn't make it any more readable, more the contrary. Also don't bother with htonl() (calls that should've been ntohl() for "correctness") when we have the data elsewhere in host order already.
2011-10-05Unobfuscate headerVerify() exit logicPanu Matilainen1-30/+20
- Jumping forwards is one thing, jumping backwards and forwards to an exit label residing in the middle of a function is something else... Refactor to single point of exit, at the end of the function. - Handle the no header-only signature/digest case (whether disabled or v3 package) and cleanup centrally at the exit label, everything falls through there now.
2011-10-05Eliminate pointless exit label from headerVerify()Panu Matilainen1-3/+0
- pgpNewDig() like most rpm "constructor" functions cannot fail, no point checking the result. Allows an icky backwards goto + label to be eliminated.
2011-10-04Push couple of variables to more local scopePanu Matilainen1-3/+3
- No functional changes, just preparing to tidy up the headerVerify() monster a bit.
2011-10-04Eliminate redundant local variable in headerLoad()Panu Matilainen1-2/+0
2011-10-03Sanity check region length on header loadPanu Matilainen1-0/+5
- Region size can't obviously be larger than the containing header, sanity check to avoid crashes from malformed packages. - We should really test for length equality here, but with dribbles the size is sometimes off by three, whatever the reason (bug likely), leaving that investigation for some sunnier day...
2011-09-29Sanity check region offset range on headerLoad()Panu Matilainen1-1/+1
- Fixes the first case crash of RhBug:741606 / CVE-2011-3378 where immutable region offset is way out of bounds.
2011-09-29Sanity check region offset in regionSwab()Panu Matilainen1-0/+3
- Region offsets are supposed to be negative when when an entry is involved, otherwise zero. Fixes some cases of crash'n'burn on malformed headers having bogus offsets (CVE-2011-3378)
2011-09-15Fix up a few strict-prototype warnings on x86Panu Matilainen1-3/+3
2011-09-15Kick out ppc arch detection leftoversPanu Matilainen1-12/+0
- This should've been in commit 6e2f56fe25a9ee62af51e0408861a8a43c97a709 all the way back then, unused ever since...
2011-09-15Eliminate hysterical copy-paste comments from rpmrcPanu Matilainen1-16/+0
2011-09-15Bit of rpmrc spring-cleaning: nuke detection for some extinct creaturesPanu Matilainen1-57/+3
2011-09-12Actually remember scriptlet flags in the rpmScript structPanu Matilainen1-2/+3
- Currently doesn't make any difference but since we actually have a flags member in the struct, might as well use it. Also we'll shortly be needing these during the actual execution too.
2011-09-12Rename scriptlet flags from RPMSCRIPT_FOO to RPMSCRIPT_FLAG_FOOPanu Matilainen2-5/+5
- No functional changes (and this is still internal-only API), just making more obvious what they are and clearing the RPMSCRIPT_FOO namespace for possible future use for the scriptlet types themselves.
2011-09-12Scriptlet argument tags are really arraysPanu Matilainen1-7/+7
- While the vast majority of scriptlet interpreters only consist of the interpreter name itself, they all can consist of arbitrary number of extra arguments. Rpm itself doesn't really care whether the tags are strings or string arrays but the scalar definition causes the rest of arguments to be invisible from eg python. Also having the type shown as string array hints at the proper query format when accessing these (and rpm itself is doing it wrong too in --scripts alias). Related to ticket #847.
2011-09-06Add four new extension tags for pretty-formatting dependenciesPanu Matilainen2-0/+49
- The current method that --requires and friends use is kinda cumbersome and outputs extra whitespace for dependencies which dont have flags+version attached. Adding extensions for this is likely to be easier than teaching query formatting to permit conditionalizing on current value instead of just tag existence.
2011-09-02Make rpmScript opaquePanu Matilainen3-12/+20
- Add accessor for fetching the script tag, the final piece that psm needs (and will continue to do so) from script internals. This allows the script type to become opaque for real.
2011-09-02Add an API for creating real rpmScript items out of triggers, use itPanu Matilainen3-37/+53
- Bury rpmScriptNew() into being internal helper in rpmscript - triggers and other scripts differ quite a bit in how their data is laid out in the header, especially args need "special attention". - Besides cleaning up things in the psm side, this technically makes trigger scripts runnable without having a header at hand. Of course currently trigger scripts are currently created and destroyed on the spot from headers so this is of academic interest...
2011-09-02First step towards unifying triggers into rpmScript APIPanu Matilainen3-44/+47
- Add a lower level script creation function to deal with the body expansions and such, use it for triggers as well. - This is still fairly ugly but its something that can be reasonably backported to 4.9.x which needs this too, as currently triggers are forgetting to set script->descr, causing "(null) failure" messages on glibc and on others, in would just crash on trigger failure and/or in debug verbosity level.
2011-09-01Don't add config() provides if config install is disabledPanu Matilainen1-0/+5
- Similarly to commit 40ee8e7427ace319687dd36bd5f745d1ef2f2236, take --noconfigs into account for the virtual config() provides too
2011-09-01Don't add file provides for doc/config files if they wont be installedPanu Matilainen1-0/+8
- Files which dont get installed cannot very well satisfy dependencies, take this into account for docs and configs when --nodocs & --noconfigs flags are used.
2011-09-01Pass tsflags to rpmal and remember themPanu Matilainen4-4/+12
- No functional changes here, but we'll need to know some of these bits for accurately calculating various dependency bits later on.
2011-09-01Source formatting cosmetics: function blocks start on the next linePanu Matilainen6-17/+32
2011-09-01Only consider installed files when looking at removed dependenciesPanu Matilainen1-1/+2
- Non-installed files cannot very well have dependencies, this eliminates some bogosities from those cases.
2011-09-01Add RPMTAG_INSTFILENAMES tag extension for state-aware file listsPanu Matilainen3-21/+48
- For a more consistent experience wrt all the state-awareness stuff, this needs to be easily querifiable too. - Also makes the tagnames kludgery from commit cac8c389607d7a5735b2905035fdfe4404670d06 unnecessary
2011-09-01Add + use helper macro for testing for installed file statePanu Matilainen2-2/+3