Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP curl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP curl
Commits
0cacbc89
Commit
0cacbc89
authored
23 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
always allocates at least 64 bytes for real, and damages them before free
parent
6753c3c7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/memdebug.c
+30
-8
30 additions, 8 deletions
lib/memdebug.c
with
30 additions
and
8 deletions
lib/memdebug.c
+
30
−
8
View file @
0cacbc89
...
...
@@ -47,6 +47,11 @@
/* DONT include memdebug.h here! */
struct
memdebug
{
int
size
;
char
mem
[
1
];
};
/*
* Note that these debug functions are very simple and they are meant to
* remain so. For advanced analysis, record a log file and write perl scripts
...
...
@@ -67,15 +72,21 @@ void curl_memdebug(const char *logname)
}
void
*
curl_domalloc
(
size_t
size
,
int
line
,
const
char
*
source
)
void
*
curl_domalloc
(
size_t
wanted
size
,
int
line
,
const
char
*
source
)
{
void
*
mem
=
(
malloc
)(
size
);
void
*
mem
;
size_t
size
;
/* alloc at least 64 bytes */
size
=
wantedsize
>
64
?
wantedsize
:
64
;
mem
=
(
malloc
)(
size
);
if
(
mem
)
/* fill memory with junk */
memset
(
mem
,
0xA5
,
size
);
if
(
logfile
)
if
(
logfile
&&
source
)
fprintf
(
logfile
,
"MEM %s:%d malloc(%d) = %p
\n
"
,
source
,
line
,
size
,
mem
);
source
,
line
,
wanted
size
,
mem
);
return
mem
;
}
...
...
@@ -90,20 +101,28 @@ char *curl_dostrdup(const char *str, int line, const char *source)
exit
(
2
);
}
mem
=
(
strdup
)(
str
);
len
=
strlen
(
str
)
+
1
;
mem
=
curl_domalloc
(
len
,
0
,
NULL
);
/* NULL prevents logging */
memcpy
(
mem
,
str
,
len
);
if
(
logfile
)
fprintf
(
logfile
,
"MEM %s:%d strdup(%p) (%d) = %p
\n
"
,
source
,
line
,
str
,
len
,
mem
);
return
mem
;
}
void
*
curl_dorealloc
(
void
*
ptr
,
size_t
size
,
int
line
,
const
char
*
source
)
void
*
curl_dorealloc
(
void
*
ptr
,
size_t
wantedsize
,
int
line
,
const
char
*
source
)
{
void
*
mem
=
(
realloc
)(
ptr
,
size
);
void
*
mem
;
size_t
size
=
wantedsize
>
64
?
wantedsize
:
64
;
mem
=
(
realloc
)(
ptr
,
size
);
if
(
logfile
)
fprintf
(
logfile
,
"MEM %s:%d realloc(%p, %d) = %p
\n
"
,
source
,
line
,
ptr
,
size
,
mem
);
source
,
line
,
ptr
,
wanted
size
,
mem
);
return
mem
;
}
...
...
@@ -114,7 +133,10 @@ void curl_dofree(void *ptr, int line, const char *source)
source
,
line
);
exit
(
2
);
}
/* we know this is least 64 bytes, destroy this much */
memset
(
ptr
,
0x13
,
64
);
/* free for real */
(
free
)(
ptr
);
if
(
logfile
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment