Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/platform/vboot_reference/vboot_firmware/lib/stateful_util.c

Issue 2327001: VerifyKernelHeader() fills a KernelImage* (Closed) Base URL: ssh://gitrw.chromium.org/chromiumos
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 * 4 *
5 * Stub implementations of utility functions which call their linux-specific 5 * Stub implementations of utility functions which call their linux-specific
6 * equivalents. 6 * equivalents.
7 */ 7 */
8 8
9 #include "stateful_util.h" 9 #include "stateful_util.h"
10 10
11 #include <stdarg.h> 11 #include <stdarg.h>
12 #include <stdio.h> 12 #include <stdio.h>
13 #include <stdlib.h> 13 #include <stdlib.h>
14 14
15 void* StatefulSkip(MemcpyState* state, uint64_t len) {
16 if (state->overrun)
17 return NULL;
18 if (len > state->remaining_len) {
19 state->overrun = 1;
20 return NULL;
21 }
22 state->remaining_buf += len;
23 state->remaining_len -= len;
24 return state; // have to return something non-NULL
25 }
26
15 void* StatefulMemcpy(MemcpyState* state, void* dst, 27 void* StatefulMemcpy(MemcpyState* state, void* dst,
16 uint64_t len) { 28 uint64_t len) {
17 if (state->overrun) 29 if (state->overrun)
18 return NULL; 30 return NULL;
19 if (len > state->remaining_len) { 31 if (len > state->remaining_len) {
20 state->overrun = 1; 32 state->overrun = 1;
21 return NULL; 33 return NULL;
22 } 34 }
23 Memcpy(dst, state->remaining_buf, len); 35 Memcpy(dst, state->remaining_buf, len);
24 state->remaining_buf += len; 36 state->remaining_buf += len;
(...skipping 21 matching lines...) Expand all
46 return NULL; 58 return NULL;
47 if (len > state->remaining_len) { 59 if (len > state->remaining_len) {
48 state->overrun = 1; 60 state->overrun = 1;
49 return NULL; 61 return NULL;
50 } 62 }
51 Memset(state->remaining_buf, val, len); 63 Memset(state->remaining_buf, val, len);
52 state->remaining_buf += len; 64 state->remaining_buf += len;
53 state->remaining_len -= len; 65 state->remaining_len -= len;
54 return state; // have to return something non-NULL 66 return state; // have to return something non-NULL
55 } 67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698