annotate bootutil/do_match.c @ 17:632d62e5efb4

c1xx-analyze-image: add bootloader analysis
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 10 Jun 2023 06:24:15 +0000
parents fe5f7ba7f154
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * The function implemented in this module performs a single match-check
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * between the boot image being analyzed and one of the reference versions
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * from ../bootmatch directory.
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/types.h>
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <string.h>
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <strings.h>
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "../bootmatch/bootmatch.h"
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 check_for_match(image, bm)
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 u_char *image;
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 struct bootmatch *bm;
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 {
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 for (; bm->nbytes; bm++) {
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 if (bcmp(image + bm->offset, bm->refbytes, bm->nbytes))
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 return(0);
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 }
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 return(1);
fe5f7ba7f154 c139-analyze-boot utility put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 }