diff options
author | James Bottomley <JBottomley@Parallels.com> | 2012-12-06 10:55:13 +0000 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-12-06 10:55:13 +0000 |
commit | 810c068391f8e2ac381b31eb1e218ab566606ac6 (patch) | |
tree | 12fca1244e4b3411956fc6c39cae96621e762d1f | |
parent | a47f1575568a759b5a92c1ecf9b0a146652eb2c0 (diff) | |
download | efitools-810c068391f8e2ac381b31eb1e218ab566606ac6.tar.gz |
simple_file: Fix directory traversal
It was broken when the multiple entries filter was introduced
-rw-r--r-- | lib/simple_file.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/simple_file.c b/lib/simple_file.c index 52686ac..b0a516a 100644 --- a/lib/simple_file.c +++ b/lib/simple_file.c @@ -340,21 +340,23 @@ simple_dir_filter(EFI_HANDLE image, CHAR16 *name, CHAR16 *filter, for (i = 0; i < tot; i++) { int len = StrLen(next->FileName); - for (c = 0; c < filtercount; c++) { - offs = StrLen(filterarr[c]); - - if (StrCmp(&next->FileName[len - offs], filterarr[c]) == 0) { - (*result)[(*count)++] = next->FileName; - } else if (next->Attribute & EFI_FILE_DIRECTORY) { + if (next->Attribute & EFI_FILE_DIRECTORY) { (*result)[(*count)] = next->FileName; (*result)[(*count)][len] = '/'; (*result)[(*count)++][len + 1] = '\0'; - } else { - continue; + } else { + for (c = 0; c < filtercount; c++) { + offs = StrLen(filterarr[c]); + + if (StrCmp(&next->FileName[len - offs], filterarr[c]) == 0) { + (*result)[(*count)++] = next->FileName; + } else { + continue; + } + break; } - break; } - + ptr += OFFSET_OF(EFI_FILE_INFO, FileName) + (len + 1)*sizeof(CHAR16); next = ptr; } |