diff options
author | Erichong <erichong@qnap.com> | 2023-04-21 15:15:38 +0800 |
---|---|---|
committer | Namjae Jeon <linkinjeon@kernel.org> | 2023-05-17 00:05:05 +0900 |
commit | 4355a84c3b1edf55561c5ada71e2b4ed309260c7 (patch) | |
tree | 41dea09ad3c9992e2a8a87c80b836b0e002ff0af | |
parent | 1bd2214fb123e811b14690b359c4de427d66aa72 (diff) | |
download | exfatprogs-4355a84c3b1edf55561c5ada71e2b4ed309260c7.tar.gz |
lib: do not allow exfat_c2o() to return negative value
assert that clus should be >= EXFAT_FIRST_CLUSTER, instead of return
a negative value.
Acked-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Erichong <erichong@qnap.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
-rw-r--r-- | lib/libexfat.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libexfat.c b/lib/libexfat.c index d7c1df1..4fd4ac6 100644 --- a/lib/libexfat.c +++ b/lib/libexfat.c @@ -15,6 +15,7 @@ #include <errno.h> #include <wchar.h> #include <limits.h> +#include <assert.h> #include "exfat_ondisk.h" #include "libexfat.h" @@ -748,8 +749,7 @@ off_t exfat_s2o(struct exfat *exfat, off_t sect) off_t exfat_c2o(struct exfat *exfat, unsigned int clus) { - if (clus < EXFAT_FIRST_CLUSTER) - return ~0L; + assert(clus >= EXFAT_FIRST_CLUSTER); return exfat_s2o(exfat, le32_to_cpu(exfat->bs->bsx.clu_offset) + ((off_t)(clus - EXFAT_FIRST_CLUSTER) << |