@@ -3312,7 +3312,8 @@ INTERCEPTOR(__sanitizer_dirent *, readdir, void *dirp) {
3312
3312
// its metadata. See
3313
3313
// https://github.com/google/sanitizers/issues/321.
3314
3314
__sanitizer_dirent *res = REAL (readdir)(dirp);
3315
- if (res) COMMON_INTERCEPTOR_WRITE_RANGE (ctx, res, res->d_reclen );
3315
+ if (res)
3316
+ COMMON_INTERCEPTOR_WRITE_RANGE (ctx, res, __sanitizer_dirsiz (res));
3316
3317
return res;
3317
3318
}
3318
3319
@@ -3327,7 +3328,7 @@ INTERCEPTOR(int, readdir_r, void *dirp, __sanitizer_dirent *entry,
3327
3328
if (!res) {
3328
3329
COMMON_INTERCEPTOR_WRITE_RANGE (ctx, result, sizeof (*result));
3329
3330
if (*result)
3330
- COMMON_INTERCEPTOR_WRITE_RANGE (ctx, *result, (*result)-> d_reclen );
3331
+ COMMON_INTERCEPTOR_WRITE_RANGE (ctx, *result, __sanitizer_dirsiz (*result));
3331
3332
}
3332
3333
return res;
3333
3334
}
@@ -3348,7 +3349,8 @@ INTERCEPTOR(__sanitizer_dirent64 *, readdir64, void *dirp) {
3348
3349
// its metadata. See
3349
3350
// https://github.com/google/sanitizers/issues/321.
3350
3351
__sanitizer_dirent64 *res = REAL (readdir64)(dirp);
3351
- if (res) COMMON_INTERCEPTOR_WRITE_RANGE (ctx, res, res->d_reclen );
3352
+ if (res)
3353
+ COMMON_INTERCEPTOR_WRITE_RANGE (ctx, res, __sanitizer_dirsiz (res));
3352
3354
return res;
3353
3355
}
3354
3356
@@ -3363,7 +3365,7 @@ INTERCEPTOR(int, readdir64_r, void *dirp, __sanitizer_dirent64 *entry,
3363
3365
if (!res) {
3364
3366
COMMON_INTERCEPTOR_WRITE_RANGE (ctx, result, sizeof (*result));
3365
3367
if (*result)
3366
- COMMON_INTERCEPTOR_WRITE_RANGE (ctx, *result, (*result)-> d_reclen );
3368
+ COMMON_INTERCEPTOR_WRITE_RANGE (ctx, *result, __sanitizer_dirsiz (*result));
3367
3369
}
3368
3370
return res;
3369
3371
}
@@ -3935,17 +3937,17 @@ static THREADLOCAL scandir_compar_f scandir_compar;
3935
3937
3936
3938
static int wrapped_scandir_filter (const struct __sanitizer_dirent *dir) {
3937
3939
COMMON_INTERCEPTOR_UNPOISON_PARAM (1 );
3938
- COMMON_INTERCEPTOR_INITIALIZE_RANGE (dir, dir-> d_reclen );
3940
+ COMMON_INTERCEPTOR_INITIALIZE_RANGE (dir, __sanitizer_dirsiz ( dir) );
3939
3941
return scandir_filter (dir);
3940
3942
}
3941
3943
3942
3944
static int wrapped_scandir_compar (const struct __sanitizer_dirent **a,
3943
3945
const struct __sanitizer_dirent **b) {
3944
3946
COMMON_INTERCEPTOR_UNPOISON_PARAM (2 );
3945
3947
COMMON_INTERCEPTOR_INITIALIZE_RANGE (a, sizeof (*a));
3946
- COMMON_INTERCEPTOR_INITIALIZE_RANGE (*a, (*a)-> d_reclen );
3948
+ COMMON_INTERCEPTOR_INITIALIZE_RANGE (*a, __sanitizer_dirsiz (*a));
3947
3949
COMMON_INTERCEPTOR_INITIALIZE_RANGE (b, sizeof (*b));
3948
- COMMON_INTERCEPTOR_INITIALIZE_RANGE (*b, (*b)-> d_reclen );
3950
+ COMMON_INTERCEPTOR_INITIALIZE_RANGE (*b, __sanitizer_dirsiz (*b));
3949
3951
return scandir_compar (a, b);
3950
3952
}
3951
3953
@@ -3969,7 +3971,7 @@ INTERCEPTOR(int, scandir, char *dirp, __sanitizer_dirent ***namelist,
3969
3971
COMMON_INTERCEPTOR_WRITE_RANGE (ctx, *namelist, sizeof (**namelist) * res);
3970
3972
for (int i = 0 ; i < res; ++i)
3971
3973
COMMON_INTERCEPTOR_WRITE_RANGE (ctx, (*namelist)[i],
3972
- ( *namelist)[i]-> d_reclen );
3974
+ __sanitizer_dirsiz (( *namelist)[i]) );
3973
3975
}
3974
3976
return res;
3975
3977
}
@@ -3988,17 +3990,17 @@ static THREADLOCAL scandir64_compar_f scandir64_compar;
3988
3990
3989
3991
static int wrapped_scandir64_filter (const struct __sanitizer_dirent64 *dir) {
3990
3992
COMMON_INTERCEPTOR_UNPOISON_PARAM (1 );
3991
- COMMON_INTERCEPTOR_INITIALIZE_RANGE (dir, dir-> d_reclen );
3993
+ COMMON_INTERCEPTOR_INITIALIZE_RANGE (dir, __sanitizer_dirsiz ( dir) );
3992
3994
return scandir64_filter (dir);
3993
3995
}
3994
3996
3995
3997
static int wrapped_scandir64_compar (const struct __sanitizer_dirent64 **a,
3996
3998
const struct __sanitizer_dirent64 **b) {
3997
3999
COMMON_INTERCEPTOR_UNPOISON_PARAM (2 );
3998
4000
COMMON_INTERCEPTOR_INITIALIZE_RANGE (a, sizeof (*a));
3999
- COMMON_INTERCEPTOR_INITIALIZE_RANGE (*a, (*a)-> d_reclen );
4001
+ COMMON_INTERCEPTOR_INITIALIZE_RANGE (*a, __sanitizer_dirsiz (*a));
4000
4002
COMMON_INTERCEPTOR_INITIALIZE_RANGE (b, sizeof (*b));
4001
- COMMON_INTERCEPTOR_INITIALIZE_RANGE (*b, (*b)-> d_reclen );
4003
+ COMMON_INTERCEPTOR_INITIALIZE_RANGE (*b, __sanitizer_dirsiz (*b));
4002
4004
return scandir64_compar (a, b);
4003
4005
}
4004
4006
@@ -4023,7 +4025,7 @@ INTERCEPTOR(int, scandir64, char *dirp, __sanitizer_dirent64 ***namelist,
4023
4025
COMMON_INTERCEPTOR_WRITE_RANGE (ctx, *namelist, sizeof (**namelist) * res);
4024
4026
for (int i = 0 ; i < res; ++i)
4025
4027
COMMON_INTERCEPTOR_WRITE_RANGE (ctx, (*namelist)[i],
4026
- ( *namelist)[i]-> d_reclen );
4028
+ __sanitizer_dirsiz (( *namelist)[i]) );
4027
4029
}
4028
4030
return res;
4029
4031
}
0 commit comments