Fix #91 #92: Put in if after asserts for key / value pair equal list length and max length
authorKrista Grothoff <krista@pep-project.org>
Tue, 12 Jul 2016 16:10:00 +0200
changeset 846c36be90ddd39
parent 845 d4bb3516e01c
child 848 edd76023d731
Fix #91 #92: Put in if after asserts for key / value pair equal list length and max length
src/pgp_gpg.c
     1.1 --- a/src/pgp_gpg.c	Tue Jul 12 14:26:50 2016 +0200
     1.2 +++ b/src/pgp_gpg.c	Tue Jul 12 16:10:00 2016 +0200
     1.3 @@ -29,9 +29,17 @@
     1.4          int length = stringlist_length(keys);
     1.5          unsigned int n = (1 << length) - 1;
     1.6  
     1.7 +        // make sure we 1) have the same number of keys and values
     1.8 +        // and 2) we don't have more key/value pairs than
     1.9 +        // the size of the bitfield used to hold the indices
    1.10 +        // of key/value pairs matching keys in the config file.
    1.11          assert(length <= sizeof(unsigned int) * CHAR_BIT);
    1.12          assert(length == stringlist_length(values));
    1.13 -
    1.14 +        if (!(length == stringlist_length(values) &&
    1.15 +              length <= sizeof(unsigned int) * CHAR_BIT)) {
    1.16 +            return false;
    1.17 +        }
    1.18 +        
    1.19          do {
    1.20              char * s;
    1.21