diff options
| author | bouyer <bouyer@NetBSD.org> | 2018-03-06 17:40:04 +0000 |
|---|---|---|
| committer | bouyer <bouyer@NetBSD.org> | 2018-03-06 17:40:04 +0000 |
| commit | 26ea6839254eac6210df80ec1d3e9c8cd95d6044 (patch) | |
| tree | e5602c5941a93d6ecfc0acd9746d212439ffb225 /sys/dev/fdt | |
| parent | 559705543e7dba7d9740517f33f2524c56b550e0 (diff) | |
fdtbus_get_string_index(): decrease len when going to the next string,
otherwise we may read past the end of names.
Diffstat (limited to 'sys/dev/fdt')
| -rw-r--r-- | sys/dev/fdt/fdt_subr.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/dev/fdt/fdt_subr.c b/sys/dev/fdt/fdt_subr.c index 39cce68ddf1..c1a5fc1b80e 100644 --- a/sys/dev/fdt/fdt_subr.c +++ b/sys/dev/fdt/fdt_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_subr.c,v 1.20 2017/12/10 21:38:27 skrll Exp $ */ +/* $NetBSD: fdt_subr.c,v 1.21 2018/03/06 17:40:04 bouyer Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.20 2017/12/10 21:38:27 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.21 2018/03/06 17:40:04 bouyer Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -467,7 +467,7 @@ fdtbus_get_string_index(int phandle, const char *prop, u_int index) names = fdtbus_get_string(phandle, prop); for (name = names, cur = 0; len > 0; - name += strlen(name) + 1, cur++) { + len -= strlen(name) + 1, name += strlen(name) + 1, cur++) { if (index == cur) return name; } |
