Files
OpenCellular/tests/futility/binary_editor.c
Bill Richardson 6f3961507e futility: Add remaining vboot binary utilities
This change adds these formerly external utilities into the futility binary:

  dev_sign_file
  dump_kernel_config
  gbb_utility
  vbutil_firmware
  vbutil_kernel

These target binaries will remain independent of futility, since they are
not directly related to verified boot:

  cgpt
  crossystem
  tpm_init_temp_fix
  tpmc

Also, dumpRSAPublicKey is removed from the target, since it is only used on
the build host to create new keypairs.

This change also add several additional tests.

BUG=chromium:224734
BRANCH=ToT
CQ-DEPEND=CL:210391,CL:210568,CL:210587
TEST=manual

make runtests
make clean

Also build and test:
- normal image
- test image
- recovery image
- firmware shellball

Note that this CL depends on simultaneous changes to the chromeos-initramfs
ebuild.

Change-Id: If791b5e9b5aac218ceafa9f45fc1785f16b91a64
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210403
2014-07-31 22:46:27 +00:00

40 lines
932 B
C

/*
* Copyright 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* This is a very simple binary editor, used to create corrupted structs for
* testing. It copies stdin to stdout, replacing bytes beginning at the given
* offset with the specified 8-bit values.
*
* There is NO conversion checking of the arguments.
*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
uint32_t offset, curpos, curarg;
int c;
if (argc < 3) {
fprintf(stderr, "Need two or more args: OFFSET VAL [VAL...]\n");
return 1;
}
offset = (uint32_t)strtoul(argv[1], 0, 0);
curarg = 2;
for ( curpos = 0; (c = fgetc(stdin)) != EOF; curpos++) {
if (curpos == offset && curarg < argc) {
c = (uint8_t)strtoul(argv[curarg++], 0, 0);
offset++;
}
fputc(c, stdout);
}
return 0;
}