struct oc_vpn_proto *pr;
int i;
- *protos = pr = calloc(NR_PROTOS, sizeof(*pr));
+ /* The original version of this function included an all-zero
+ * sentinel value at the end of the array, so we must continue
+ * to do so for ABI compatibility even though it's
+ * functionally redundant as a marker of the array's length,
+ * along with the explicit length in the return value.
+ */
+ *protos = pr = calloc(NR_PROTOS + 1, sizeof(*pr));
if (!pr)
return -ENOMEM;
{
const char *comma = ", ", *sep = comma + 1;
struct oc_vpn_proto *protos, *p;
+ int n;
- if (openconnect_get_supported_protocols(&protos)>=0) {
+ n = openconnect_get_supported_protocols(&protos);
+ if (n>=0) {
printf(_("Supported protocols:"));
- for (p=protos; p->name; p++) {
+ for (p=protos; n; p++, n--) {
printf("%s%s%s", sep, p->name, p==protos ? _(" (default)") : "");
sep = comma;
}
static void print_supported_protocols_usage(void)
{
struct oc_vpn_proto *protos, *p;
+ int n;
- if (openconnect_get_supported_protocols(&protos)>=0) {
+ n = openconnect_get_supported_protocols(&protos);
+ if (n>=0) {
printf("\n%s:\n", _("Set VPN protocol"));
- for (p=protos; p->name; p++)
+ for (p=protos; n; p++, n--)
printf(" --protocol=%-16s %s%s\n",
p->name, p->description, p==protos ? _(" (default)") : "");
openconnect_free_supported_protocols(protos);