summaryrefslogtreecommitdiffstats
path: root/apps/srp.c
diff options
context:
space:
mode:
authorDiego Santa Cruz <Diego.SantaCruz@spinetix.com>2017-05-17 10:17:59 +0200
committerAndy Polyakov <appro@openssl.org>2017-05-19 11:42:23 +0200
commit5ec3210fc106ecc6badb48db6cfb1493a7607763 (patch)
treed21cb2723a5806298f5b61b8397d98e703f48b84 /apps/srp.c
parent9bfeeef8ee2220339e601a028fa991c30d296ed4 (diff)
Fix endless loop on srp app when listing users
With the -list option the srp app loops on the main while() endlessly, whether users were given on the command line or not. The loop should be stopped when in list mode and there are no more users. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3489)
Diffstat (limited to 'apps/srp.c')
-rw-r--r--apps/srp.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/apps/srp.c b/apps/srp.c
index be4a4b43d3..b14530fce3 100644
--- a/apps/srp.c
+++ b/apps/srp.c
@@ -37,13 +37,14 @@ static int get_index(CA_DB *db, char *id, char type)
int i;
if (id == NULL)
return -1;
- if (type == DB_SRP_INDEX)
+ if (type == DB_SRP_INDEX) {
for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) {
pp = sk_OPENSSL_PSTRING_value(db->db->data, i);
if (pp[DB_srptype][0] == DB_SRP_INDEX
&& strcmp(id, pp[DB_srpid]) == 0)
return i;
- } else
+ }
+ } else {
for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) {
pp = sk_OPENSSL_PSTRING_value(db->db->data, i);
@@ -51,6 +52,7 @@ static int get_index(CA_DB *db, char *id, char type)
&& strcmp(id, pp[DB_srpid]) == 0)
return i;
}
+ }
return -1;
}
@@ -549,10 +551,11 @@ int srp_main(int argc, char **argv)
doupdatedb = 1;
}
}
- if (--argc > 0)
+ if (--argc > 0) {
user = *(argv++);
- else {
- user = NULL;
+ } else {
+ /* no more processing in any mode if no users left */
+ break;
}
}