Skip to content

Commit

Permalink
Fix CID 1547469: Integer handling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ni4 authored and antonsviridenko committed Jul 28, 2024
1 parent 40be6c3 commit dcbfe13
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib/fingerprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*/

#include <string.h>
#include <cassert>
#include "fingerprint.h"
#include "crypto/hash.hpp"
#include <librepgp/stream-key.h>
Expand Down Expand Up @@ -106,8 +107,13 @@ pgp_keyid(pgp_key_id_t &keyid, const pgp_key_pkt_t &key)
if (ret) {
return ret;
}
size_t inc = key.version == PGP_V4 ? fp.length - keyid.size() : 0;
(void) memcpy(keyid.data(), fp.fingerprint + inc, keyid.size());
if (key.version == PGP_V4) {
assert(fp.length == PGP_FINGERPRINT_V4_SIZE);
const size_t inc = PGP_FINGERPRINT_V4_SIZE - PGP_KEY_ID_SIZE;
memcpy(keyid.data(), fp.fingerprint + inc, keyid.size());
} else {
memcpy(keyid.data(), fp.fingerprint, keyid.size());
}
return RNP_SUCCESS;
}
default:
Expand Down

0 comments on commit dcbfe13

Please sign in to comment.