OLD | NEW |
---|---|
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 * Functions for generating and manipulating a verified boot kernel image. | 5 * Functions for generating and manipulating a verified boot kernel image. |
6 * (Userland portion) | 6 * (Userland portion) |
7 */ | 7 */ |
8 #include "kernel_image.h" | 8 #include "kernel_image.h" |
9 | 9 |
10 #include <fcntl.h> | 10 #include <fcntl.h> |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 if (st.remaining_len < on_disk_padding) | 169 if (st.remaining_len < on_disk_padding) |
170 st.overrun = -1; | 170 st.overrun = -1; |
171 st.remaining_buf += on_disk_padding; | 171 st.remaining_buf += on_disk_padding; |
172 st.remaining_len -= on_disk_padding; | 172 st.remaining_len -= on_disk_padding; |
173 } | 173 } |
174 | 174 |
175 /* Read kernel image data. */ | 175 /* Read kernel image data. */ |
176 image->kernel_data = (uint8_t*) Malloc(image->kernel_len); | 176 image->kernel_data = (uint8_t*) Malloc(image->kernel_len); |
177 StatefulMemcpy(&st, image->kernel_data, image->kernel_len); | 177 StatefulMemcpy(&st, image->kernel_data, image->kernel_len); |
178 | 178 |
179 if(st.overrun || st.remaining_len != 0) { /* Overrun or underrun. */ | 179 if(st.overrun) { |
gauravsh
2010/05/28 07:22:43
add a comment here that underruns are ok here?
| |
180 Free(kernel_buf); | 180 Free(kernel_buf); |
181 return NULL; | 181 return NULL; |
182 } | 182 } |
183 Free(kernel_buf); | 183 Free(kernel_buf); |
184 return image; | 184 return image; |
185 } | 185 } |
186 | 186 |
187 int GetKernelHeaderLen(const KernelImage* image) { | 187 int GetKernelHeaderLen(const KernelImage* image) { |
188 return (FIELD_LEN(header_version) + FIELD_LEN(header_len) + | 188 return (FIELD_LEN(header_version) + FIELD_LEN(header_len) + |
189 FIELD_LEN(firmware_sign_algorithm) + | 189 FIELD_LEN(firmware_sign_algorithm) + |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
751 // Clean up and return the blob. | 751 // Clean up and return the blob. |
752 done3: | 752 done3: |
753 Free(bootloader_buf); | 753 Free(bootloader_buf); |
754 done2: | 754 done2: |
755 Free(config_buf); | 755 Free(config_buf); |
756 done1: | 756 done1: |
757 Free(kernel_buf); | 757 Free(kernel_buf); |
758 done0: | 758 done0: |
759 return blob; | 759 return blob; |
760 } | 760 } |
OLD | NEW |