提交 5ec3210f 编写于 作者: D Diego Santa Cruz 提交者: Andy Polyakov

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: NRich Salz <rsalz@openssl.org>
Reviewed-by: NAndy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3489)
上级 9bfeeef8
......@@ -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;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册