diff --git a/src/lib/libutil/ber.c b/src/lib/libutil/ber.c index 4fb4e7ba..f38d95b9 100644 --- a/src/lib/libutil/ber.c +++ b/src/lib/libutil/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.11 2019/08/05 12:38:14 martijn Exp $ */ +/* $OpenBSD: ber.c,v 1.12 2019/08/14 04:48:13 martijn Exp $ */ /* * Copyright (c) 2007, 2012 Reyk Floeter @@ -684,6 +684,8 @@ ber_scanf_elements(struct ber_element *ber, char *fmt, ...) va_start(ap, fmt); while (*fmt) { + if (ber == NULL && *fmt != '}' && *fmt != ')') + goto fail; switch (*fmt++) { case 'B': ptr = va_arg(ap, void **); @@ -788,8 +790,6 @@ ber_scanf_elements(struct ber_element *ber, char *fmt, ...) goto fail; } - if (ber->be_next == NULL) - continue; ber = ber->be_next; } va_end(ap);