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
bf43b49a
Commit
bf43b49a
authored
24 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
added socket() / sclose() checks to the memdebug system
parent
6ad9bd80
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/memdebug.c
+27
-0
27 additions, 0 deletions
lib/memdebug.c
lib/memdebug.h
+13
-0
13 additions, 0 deletions
lib/memdebug.h
memanalyze.pl
+29
-0
29 additions, 0 deletions
memanalyze.pl
with
69 additions
and
0 deletions
lib/memdebug.c
+
27
−
0
View file @
bf43b49a
...
...
@@ -43,6 +43,14 @@
#include
<curl/curl.h>
#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
#include
<winsock.h>
#else
/* some kind of unix */
#ifdef HAVE_SYS_SOCKET_H
#include
<sys/socket.h>
#endif
#endif
#define _MPRINTF_REPLACE
#include
<curl/mprintf.h>
#include
"urldata.h"
...
...
@@ -50,6 +58,8 @@
#include
<string.h>
#include
<stdlib.h>
/* DONT include memdebug.h here! */
/*
* 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
...
...
@@ -115,4 +125,21 @@ void curl_dofree(void *ptr, int line, char *source)
source
,
line
,
ptr
);
}
int
curl_socket
(
int
domain
,
int
type
,
int
protocol
,
int
line
,
char
*
source
)
{
int
sockfd
=
(
socket
)(
domain
,
type
,
protocol
);
fprintf
(
logfile
?
logfile
:
stderr
,
"FD %s:%d socket() = %d
\n
"
,
source
,
line
,
sockfd
);
return
sockfd
;
}
/* this is our own defined way to close sockets on *ALL* platforms */
int
curl_sclose
(
int
sockfd
,
int
line
,
char
*
source
)
{
int
res
=
sclose
(
sockfd
);
fprintf
(
logfile
?
logfile
:
stderr
,
"FD %s:%d sclose(%d)
\n
"
,
source
,
line
,
sockfd
);
return
sockfd
;
}
#endif
/* MALLOCDEBUG */
This diff is collapsed.
Click to expand it.
lib/memdebug.h
+
13
−
0
View file @
bf43b49a
#ifdef MALLOCDEBUG
/* memory functions */
void
*
curl_domalloc
(
size_t
size
,
int
line
,
char
*
source
);
void
*
curl_dorealloc
(
void
*
ptr
,
size_t
size
,
int
line
,
char
*
source
);
void
curl_dofree
(
void
*
ptr
,
int
line
,
char
*
source
);
char
*
curl_dostrdup
(
char
*
str
,
int
line
,
char
*
source
);
void
curl_memdebug
(
char
*
logname
);
/* file descriptor manipulators */
int
curl_socket
(
int
domain
,
int
type
,
int
protocol
,
int
,
char
*
);
int
curl_sclose
(
int
sockfd
,
int
,
char
*
);
/* Set this symbol on the command-line, recompile all lib-sources */
#define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
#define malloc(size) curl_domalloc(size, __LINE__, __FILE__)
#define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__)
#define free(ptr) curl_dofree(ptr, __LINE__, __FILE__)
#define socket(domain,type,protocol)\
curl_socket(domain,type,protocol,__LINE__,__FILE__)
/* sclose is probably already defined, redefine it! */
#undef sclose
#define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
#endif
This diff is collapsed.
Click to expand it.
memanalyze.pl
+
29
−
0
View file @
bf43b49a
...
...
@@ -72,6 +72,28 @@ while(<STDIN>) {
print
"
Not recognized input line:
$function
\n
";
}
}
# FD url.c:1282 socket() = 5
elsif
(
$_
=~
/^FD ([^:]*):(\d*) (.*)/
)
{
# generic match for the filename+linenumber
$source
=
$
1
;
$linenum
=
$
2
;
$function
=
$
3
;
if
(
$function
=~
/socket\(\) = (\d*)/
)
{
$filedes
{
$
1
}
=
1
;
$getfile
{
$
1
}
=
"
$source
:
$linenum
";
$openfile
++
;
}
elsif
(
$function
=~
/sclose\((\d*)\)/
)
{
if
(
$filedes
{
$
1
}
!=
1
)
{
print
"
Close without open:
$line
\n
";
}
else
{
$filedes
{
$
1
}
=
0
;
# closed now
$openfile
--
;
}
}
}
else
{
print
"
Not recognized prefix line:
$line
\n
";
}
...
...
@@ -93,3 +115,10 @@ if($totalmem) {
}
}
if
(
$openfile
)
{
for
(
keys
%filedes
)
{
if
(
$filedes
{
$_
}
==
1
)
{
print
"
Open file descriptor created at
"
.
$getfile
{
$_
}
.
"
\n
";
}
}
}
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