diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2024-03-24 05:50:21 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2024-03-24 05:50:21 +0000 |
commit | a042eb0eec95d0c338b71318b47170f14f7f6715 (patch) | |
tree | 62444843ca7f5636cd8d44c7c06d051bbbc7fd61 /sys | |
parent | a49bddca8d5e3eb8b3b241040859db093fd7e8d0 (diff) |
use LIST_FOREACH_SAFE() to avoid use after free
this can't happen in a libsa environment
found by smatch, ok jsing@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/lib/libsa/softraid.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/lib/libsa/softraid.c b/sys/lib/libsa/softraid.c index 76f1fece3bd..d31c167e0e4 100644 --- a/sys/lib/libsa/softraid.c +++ b/sys/lib/libsa/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.5 2022/08/12 20:17:46 stsp Exp $ */ +/* $OpenBSD: softraid.c,v 1.6 2024/03/24 05:50:20 jsg Exp $ */ /* * Copyright (c) 2012 Joel Sing <jsing@openbsd.org> @@ -63,7 +63,7 @@ void sr_clear_keys(void) { struct sr_boot_volume *bv; - struct sr_boot_keydisk *kd; + struct sr_boot_keydisk *kd, *nkd; SLIST_FOREACH(bv, &sr_volumes, sbv_link) { if (bv->sbv_level != 'C' && bv->sbv_level != 0x1C) @@ -79,7 +79,7 @@ sr_clear_keys(void) bv->sbv_maskkey = NULL; } } - SLIST_FOREACH(kd, &sr_keydisks, kd_link) { + SLIST_FOREACH_SAFE(kd, &sr_keydisks, kd_link, nkd) { explicit_bzero(kd, sizeof(*kd)); free(kd, sizeof(*kd)); } |