...
|
...
|
@@ -2970,7 +2970,8 @@ int cli_map_scan(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx)
|
2970
|
2970
|
|
2971
|
2971
|
cli_dbgmsg("cli_map_scan: [%ld, +%lu)\n",
|
2972
|
2972
|
(long)offset, (unsigned long)length);
|
2973
|
|
- if (offset < 0 || offset >= map->len) {
|
|
2973
|
+
|
|
2974
|
+ if (offset < 0 || offset >= old_len) {
|
2974
|
2975
|
cli_dbgmsg("Invalid offset: %ld\n", (long)offset);
|
2975
|
2976
|
return CL_CLEAN;
|
2976
|
2977
|
}
|
...
|
...
|
@@ -2982,6 +2983,24 @@ int cli_map_scan(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx)
|
2982
|
2982
|
int fd = -1;
|
2983
|
2983
|
size_t nread = 0;
|
2984
|
2984
|
|
|
2985
|
+ /* Then check length */
|
|
2986
|
+ if (!length) length = old_len - offset;
|
|
2987
|
+ if (length > old_len - offset) {
|
|
2988
|
+ cli_dbgmsg("cli_map_scan: Data truncated: %lu -> %lu\n",
|
|
2989
|
+ (unsigned long)length, (unsigned long)(old_len - offset));
|
|
2990
|
+ length = old_len - offset;
|
|
2991
|
+ }
|
|
2992
|
+ if (length <= 5) {
|
|
2993
|
+ cli_dbgmsg("cli_map_scan: Small data (%u bytes)\n", (unsigned int) length);
|
|
2994
|
+ return CL_CLEAN;
|
|
2995
|
+ }
|
|
2996
|
+ if (!CLI_ISCONTAINED(old_off, old_len, old_off + offset, length)) {
|
|
2997
|
+ cli_dbgmsg("cli_map_scan: map error occurred [%ld, %lu]\n",
|
|
2998
|
+ (long)old_off, (unsigned long)old_len);
|
|
2999
|
+ return CL_CLEAN;
|
|
3000
|
+ }
|
|
3001
|
+
|
|
3002
|
+ /* Length checked, now get map */
|
2985
|
3003
|
mapdata = fmap_need_off_once_len(map, offset, length, &nread);
|
2986
|
3004
|
if (!mapdata || (nread != length)) {
|
2987
|
3005
|
cli_errmsg("cli_map_scan: could not map sub-file\n");
|