diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-06-23 02:30:31 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-06-23 02:30:31 +0000 |
commit | 783fce1a7d91cdd961cbcc70c67488f1b48d2a95 (patch) | |
tree | e2efaa696497cedc92627849723ef1c48b764f6c | |
parent | 4f36a18db8d324e8495f2a237e4824c03182e4ab (diff) | |
parent | b7af06bff64a85a53db9fb5a32f0860c7f2588be (diff) | |
download | fsck_msdos-783fce1a7d91cdd961cbcc70c67488f1b48d2a95.tar.gz |
Snap for 7483611 from b7af06bff64a85a53db9fb5a32f0860c7f2588be to mainline-neuralnetworks-releaseandroid-mainline-12.0.0_r92android-mainline-12.0.0_r78android-mainline-12.0.0_r50android-mainline-12.0.0_r33android-mainline-12.0.0_r3android12-mainline-neuralnetworks-release
Change-Id: Id38b9d6d109887f9148dfe98d8862579d0d5d677
-rw-r--r-- | Android.bp | 17 | ||||
-rw-r--r-- | check.c | 4 | ||||
-rw-r--r-- | dir.c | 17 |
3 files changed, 32 insertions, 6 deletions
@@ -1,3 +1,20 @@ +package { + default_applicable_licenses: ["external_fsck_msdos_license"], +} + +// Added automatically by a large-scale-change +// See: http://go/android-license-faq +license { + name: "external_fsck_msdos_license", + visibility: [":__subpackages__"], + license_kinds: [ + "SPDX-license-identifier-BSD", + ], + license_text: [ + "NOTICE", + ], +} + cc_binary { name: "fsck_msdos", srcs: [ @@ -186,8 +186,10 @@ checkfilesys(const char *fname) free(fat); close(dosfs); - if (mod & (FSFATMOD|FSDIRMOD)) + if (mod & (FSFATMOD|FSDIRMOD)){ pwarn("\n***** FILE SYSTEM WAS MODIFIED *****\n"); + return 4; + } return ret; } @@ -388,7 +388,8 @@ static int checksize(struct fat_descriptor *fat, u_char *p, struct dosDirEntry *dir) { int ret = FSOK; - size_t physicalSize; + size_t chainsize; + u_int64_t physicalSize; struct bootblock *boot; boot = fat_get_boot(fat); @@ -401,9 +402,9 @@ checksize(struct fat_descriptor *fat, u_char *p, struct dosDirEntry *dir) } else { if (!fat_is_valid_cl(fat, dir->head)) return FSERROR; - ret = checkchain(fat, dir->head, &physicalSize); + ret = checkchain(fat, dir->head, &chainsize); /* - * Upon return, physicalSize would hold the chain length + * Upon return, chainsize would hold the chain length * that checkchain() was able to validate, but if the user * refused the proposed repair, it would be unsafe to * proceed with directory entry fix, so bail out in that @@ -412,10 +413,16 @@ checksize(struct fat_descriptor *fat, u_char *p, struct dosDirEntry *dir) if (ret == FSERROR) { return (FSERROR); } - physicalSize *= boot->ClusterSize; + /* + * The maximum file size on FAT32 is 4GiB - 1, which + * will occupy a cluster chain of exactly 4GiB in + * size. On 32-bit platforms, since size_t is 32-bit, + * it would wrap back to 0. + */ + physicalSize = (u_int64_t)chainsize * boot->ClusterSize; } if (physicalSize < dir->size) { - pwarn("size of %s is %u, should at most be %zu\n", + pwarn("size of %s is %u, should at most be %" PRIu64 "\n", fullpath(dir), dir->size, physicalSize); if (ask(1, "Truncate")) { dir->size = physicalSize; |