Chromium Code Reviews| Index: src/trusted/service_runtime/sel_main_chrome.c |
| diff --git a/src/trusted/service_runtime/sel_main_chrome.c b/src/trusted/service_runtime/sel_main_chrome.c |
| index 88aae7cce69775a6e4d07b41e7edd6e0cbd9588f..d44a2e41d12f10c0f308f53e36c4e1460d3d42c0 100644 |
| --- a/src/trusted/service_runtime/sel_main_chrome.c |
| +++ b/src/trusted/service_runtime/sel_main_chrome.c |
| @@ -41,6 +41,7 @@ |
| #include "native_client/src/trusted/service_runtime/sel_ldr.h" |
| #include "native_client/src/trusted/service_runtime/sel_qualify.h" |
| #include "native_client/src/trusted/service_runtime/win/exception_patch/ntdll_patch.h" |
| +#include "native_client/src/trusted/validator/validation_metadata.h" |
| struct NaClChromeMainArgs *NaClChromeMainArgsCreate(void) { |
| struct NaClChromeMainArgs *args = malloc(sizeof(*args)); |
| @@ -77,10 +78,33 @@ struct NaClChromeMainArgs *NaClChromeMainArgsCreate(void) { |
| return args; |
| } |
| +static char kFakeIrtName[] = "\0IRT"; |
| + |
| +static void ValidationMetadataForFD(int file_desc, |
| + const char* file_name, |
| + size_t file_name_length, |
| + struct NaClValidationMetadata *metadata) { |
| + struct NaClHostDesc wrapper; |
| + nacl_host_stat_t stat; |
| + |
| + memset(metadata, 0, sizeof(*metadata)); |
| + wrapper.d = file_desc; |
| + if(!NaClHostDescFstat(&wrapper, &stat)) { |
| + metadata->identity_type = NaClCodeIdentityFile; |
| + /* TODO(ncbray) plumb the real filename in from Chrome. */ |
| + metadata->file_name = file_name; |
| + metadata->file_name_length = file_name_length; |
| + metadata->file_size = stat.st_size; |
| + metadata->mtime = stat.st_mtime; |
| + /* TODO(ncbray) dev / ino where available. */ |
| + } |
| +} |
| + |
| static void NaClLoadIrt(struct NaClApp *nap, int irt_fd) { |
| int file_desc; |
| struct GioPio gio_pio; |
| struct Gio *gio_desc; |
| + struct NaClValidationMetadata metadata; |
| NaClErrorCode errcode; |
| if (irt_fd == -1) { |
| @@ -92,6 +116,9 @@ static void NaClLoadIrt(struct NaClApp *nap, int irt_fd) { |
| NaClLog(LOG_FATAL, "NaClLoadIrt: Failed to dup() file descriptor\n"); |
| } |
| + ValidationMetadataForFD(file_desc, kFakeIrtName, sizeof(kFakeIrtName), |
|
bsy
2013/03/28 00:11:49
just to be clearer, maybe a comment that the kFake
|
| + &metadata); |
| + |
| /* |
| * The GioPio type is safe to use when this file descriptor is shared |
| * with other processes, because it does not use the shared file position. |
| @@ -101,7 +128,7 @@ static void NaClLoadIrt(struct NaClApp *nap, int irt_fd) { |
| } |
| gio_desc = (struct Gio *) &gio_pio; |
| - errcode = NaClAppLoadFileDynamically(nap, gio_desc); |
| + errcode = NaClAppLoadFileDynamically(nap, gio_desc, &metadata); |
| if (errcode != LOAD_OK) { |
| NaClLog(LOG_FATAL, |
| "NaClLoadIrt: Failed to load the integrated runtime (IRT): %s\n", |