mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-07 06:56:56 +01:00
Arguments for malloc and calloc should be size_t, not int.
Use proper bounds check when trying to free cached memory. Spotted by: Xin Li Tested by: Dmitry Sivachenko MFC after: 2 weeks
This commit is contained in:
parent
4477cac768
commit
eff68496e2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=262488
@ -369,7 +369,7 @@ int flushentry(void);
|
||||
* to get space.
|
||||
*/
|
||||
static inline void*
|
||||
Malloc(int size)
|
||||
Malloc(size_t size)
|
||||
{
|
||||
void *retval;
|
||||
|
||||
@ -384,7 +384,7 @@ Malloc(int size)
|
||||
* to get space.
|
||||
*/
|
||||
static inline void*
|
||||
Calloc(int cnt, int size)
|
||||
Calloc(size_t cnt, size_t size)
|
||||
{
|
||||
void *retval;
|
||||
|
||||
|
@ -225,7 +225,7 @@ cgget(int cg)
|
||||
struct cg *cgp;
|
||||
|
||||
if (cgbufs == NULL) {
|
||||
cgbufs = Calloc(sblock.fs_ncg, sizeof(struct bufarea));
|
||||
cgbufs = calloc(sblock.fs_ncg, sizeof(struct bufarea));
|
||||
if (cgbufs == NULL)
|
||||
errx(EEXIT, "cannot allocate cylinder group buffers");
|
||||
}
|
||||
@ -254,6 +254,8 @@ flushentry(void)
|
||||
{
|
||||
struct bufarea *cgbp;
|
||||
|
||||
if (flushtries == sblock.fs_ncg || cgbufs == NULL)
|
||||
return (0);
|
||||
cgbp = &cgbufs[flushtries++];
|
||||
if (cgbp->b_un.b_cg == NULL)
|
||||
return (0);
|
||||
|
Loading…
Reference in New Issue
Block a user