Browse Source

ENGINE-633: little bugs make big problems (argument order screwed up in import_keys_from_decrypted_message, failure to initialise comm_type in validate_fpr)

doxygen_doc
parent
commit
6741a6c735
5 changed files with 54 additions and 14 deletions
  1. +37
    -11
      pEpErr.py
  2. +2
    -0
      src/keymanagement.c
  3. +1
    -1
      src/message_api.c
  4. +4
    -1
      test/src/GetKeyRatingForUserTest.cc
  5. +10
    -1
      test/src/TrustManipulationTest.cc

+ 37
- 11
pEpErr.py View File

@ -8,12 +8,32 @@
#
import sys
import argparse
def parse_enum_line(line):
def parse_enum_line(line, ct):
line = line.strip()
parts = line.split()
if len(parts) != 3 or parts[1] != '=' or not parts[0].startswith("PEP_"):
if (line.startswith("//") or line == ""):
return
parts = []
if (ct):
temp = line.split(",")
if len(temp) == 0:
return
else:
parts = temp[0].split()
else:
parts = line.split()
if len(parts) != 3 or parts[1] != '=':
return
if not ct and not parts[0].startswith("PEP_"):
return
elif ct and not parts[0].startswith("PEP_ct_"):
return
key = int(parts[2].strip(','), 0)
value = parts[0]
valueDict[key] = value
@ -27,11 +47,13 @@ def get_error(code):
print(str(code) + " -> " + error)
error_val = int(sys.argv[1], 0)
if error_val == None:
print("No error code, no error status!")
exit(-1)
parser = argparse.ArgumentParser()
parser.add_argument("value", type=int)
parser.add_argument("--comm_type", "-ct", help="number represents a comm type", action='store_true')
args = parser.parse_args()
error_val = args.value
input_fname = "src/pEpEngine.h"
@ -46,16 +68,20 @@ valueDict = dict()
# If another struct is added first, expect chaos! ;)
#
for line in content:
if line.startswith("} PEP_STATUS;"):
break
if not args.comm_type:
if line.startswith("} PEP_STATUS;"):
break
else:
if line.startswith("} PEP_comm_type;"):
break
if not line.startswith("typedef enum {") and not inStruct:
if ((not args.comm_type and not line.startswith("typedef enum {")) or (args.comm_type and not line.startswith("typedef enum _PEP_comm_type {"))) and not inStruct:
continue
if not inStruct:
inStruct = True
continue
parse_enum_line(line)
parse_enum_line(line, args.comm_type)
get_error(error_val)

+ 2
- 0
src/keymanagement.c View File

@ -134,6 +134,8 @@ PEP_STATUS validate_fpr(PEP_SESSION session,
else if (status != PEP_STATUS_OK && has_private) // should never happen
has_private = false;
ident->comm_type = PEP_ct_unknown;
status = get_trust(session, ident);
if (status != PEP_STATUS_OK)
ident->comm_type = PEP_ct_unknown;


+ 1
- 1
src/message_api.c View File

@ -4236,7 +4236,7 @@ static PEP_STATUS _decrypt_message(
// otherwise, we don't ask for a sender import fpr because for pEp 2.0+ any legit default key attachments should
// be INSIDE the message
status = import_keys_from_decrypted_msg(session, msg,
&keys_were_imported, is_pEp_msg,
is_pEp_msg, &keys_were_imported,
&imported_private_key_address,
private_il,
&_imported_key_list,


+ 4
- 1
test/src/GetKeyRatingForUserTest.cc View File

@ -97,7 +97,10 @@ TEST_F(GetKeyRatingForUserTest, check_get_key_rating_for_user) {
// Ok, so we have no info really, let's set it.
status = set_identity(session, alice);
ASSERT_OK;
status = set_fpr_preserve_ident(session, alice, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", false);
ASSERT_OK;
status = update_identity(session, alice);
ASSERT_NOTNULL(alice->fpr);


+ 10
- 1
test/src/TrustManipulationTest.cc View File

@ -149,7 +149,16 @@ TEST_F(TrustManipulationTest, check_trust_manipulation) {
ASSERT_STREQ(user->fpr, keypair2);
ASSERT_EQ(user->comm_type , PEP_ct_mistrusted);
output_stream << "Hoorah, we now do not trust key 2. (We never liked key 2 anyway.)" << endl;
output_stream << "Now we call update_identity to see what gifts it gives us (should be key 1 with key 1's initial trust.)" << endl;
// Ok, here's where the test breaks when we remove key election. Update identity won't be giving us anything because there's no default.
// output_stream << "Now we call update_identity to see what gifts it gives us (should be key 1 with key 1's initial trust.)" << endl;
output_stream << "Now we call update_identity to see what gifts it gives us (should be NOTHING.)" << endl;
status = update_identity(session, user);
ASSERT_NULL(user->fpr);
// Now set key 1 as the default again
status = set_fpr_preserve_ident(session, user, keypair1, true);
ASSERT_OK;
status = update_identity(session, user);
ASSERT_NOTNULL(user->fpr);
ASSERT_STREQ(user->fpr, keypair1);


Loading…
Cancel
Save