From e93ebd453a999bd84ecee23236beb2e7dfce4a73 Mon Sep 17 00:00:00 2001 From: mlelstv Date: Sun, 30 Dec 2018 12:05:48 +0000 Subject: [PATCH] Avoid crash when no algorithm is specified in parameter file. --- sbin/cgdconfig/params.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sbin/cgdconfig/params.c b/sbin/cgdconfig/params.c index 195324d152dc..ff2ed8c11205 100644 --- a/sbin/cgdconfig/params.c +++ b/sbin/cgdconfig/params.c @@ -1,4 +1,4 @@ -/* $NetBSD: params.c,v 1.29 2016/12/11 00:34:39 alnsn Exp $ */ +/* $NetBSD: params.c,v 1.30 2018/12/30 12:05:48 mlelstv Exp $ */ /*- * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: params.c,v 1.29 2016/12/11 00:34:39 alnsn Exp $"); +__RCSID("$NetBSD: params.c,v 1.30 2018/12/30 12:05:48 mlelstv Exp $"); #endif #include @@ -158,6 +158,8 @@ params_filldefaults(struct params *p) if (!p->ivmeth) p->ivmeth = string_fromcharstar("encblkno1"); if (p->keylen == (size_t)-1) { + if (p->algorithm == NULL) + return -1; i = crypt_defaults_lookup(string_tocharstar(p->algorithm)); if (i != (size_t)-1) { p->keylen = crypto_defaults[i].keylen;