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
aa8a2fbd
Commit
aa8a2fbd
authored
24 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
GetHost() changed function arguments
parent
3471e2c5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/hostip.c
+30
-13
30 additions, 13 deletions
lib/hostip.c
lib/hostip.h
+1
-2
1 addition, 2 deletions
lib/hostip.h
with
31 additions
and
15 deletions
lib/hostip.c
+
30
−
13
View file @
aa8a2fbd
...
...
@@ -103,13 +103,22 @@ char *MakeIP(unsigned long num,char *addr, int addr_len)
#endif
struct
hostent
*
GetHost
(
struct
UrlData
*
data
,
char
*
hostname
,
char
*
buf
,
int
buf_size
)
char
**
bufp
)
{
struct
hostent
*
h
=
NULL
;
unsigned
long
in
;
int
ret
;
#define CURL_NAMELOOKUP_SIZE 9000
/* Allocate enough memory to hold the full name information structs and
* everything. OSF1 is known to require at least 8872 bytes. The buffer
* required for storing all possible aliases and IP numbers is according to
* Stevens' Unix Network Programming 2nd editor, p. 304: 8192 bytes! */
char
*
buf
=
(
char
*
)
malloc
(
CURL_NAMELOOKUP_SIZE
);
if
(
!
buf
)
return
NULL
;
/* major failure */
if
(
(
in
=
inet_addr
(
hostname
))
!=
INADDR_NONE
)
{
struct
in_addr
*
addrentry
;
...
...
@@ -123,18 +132,20 @@ struct hostent *GetHost(struct UrlData *data,
h
->
h_length
=
sizeof
(
*
addrentry
);
h
->
h_name
=
*
(
h
->
h_addr_list
)
+
h
->
h_length
;
/* bad one h->h_name = (char*)(h->h_addr_list + h->h_length); */
MakeIP
(
ntohl
(
in
),
h
->
h_name
,
buf_size
-
(
long
)(
h
->
h_name
)
+
(
long
)
buf
);
MakeIP
(
ntohl
(
in
),
h
->
h_name
,
CURL_NAMELOOKUP_SIZE
-
(
long
)(
h
->
h_name
)
+
(
long
)
buf
);
}
#if defined(HAVE_GETHOSTBYNAME_R)
else
{
int
h_errnop
;
memset
(
buf
,
0
,
buf_size
);
/* workaround for gethostbyname_r bug in qnx nto */
/* Workaround for gethostbyname_r bug in qnx nto. It is also _required_
for some of these functions. */
memset
(
buf
,
0
,
CURL_NAMELOOKUP_SIZE
);
#ifdef HAVE_GETHOSTBYNAME_R_5
/* Solaris, IRIX and more */
if
((
h
=
gethostbyname_r
(
hostname
,
(
struct
hostent
*
)
buf
,
buf
+
sizeof
(
struct
hostent
),
buf_size
-
sizeof
(
struct
hostent
),
CURL_NAMELOOKUP_SIZE
-
sizeof
(
struct
hostent
),
&
h_errnop
))
==
NULL
)
#endif
#ifdef HAVE_GETHOSTBYNAME_R_6
...
...
@@ -142,22 +153,26 @@ struct hostent *GetHost(struct UrlData *data,
if
(
gethostbyname_r
(
hostname
,
(
struct
hostent
*
)
buf
,
buf
+
sizeof
(
struct
hostent
),
buf_size
-
sizeof
(
struct
hostent
),
CURL_NAMELOOKUP_SIZE
-
sizeof
(
struct
hostent
),
&
h
,
/* DIFFERENCE */
&
h_errnop
))
#endif
#ifdef HAVE_GETHOSTBYNAME_R_3
/* AIX, Digital Unix, HPUX 10, more? */
/* August 4th, 2000. I don't have any such system around so I write this
blindly in hope it might work or that someone else will help me fix
this. August 22nd, 2000: Albert Chin-A-Young brought an updated version
that should work! */
if
(
CURL_NAMELOOKUP_SIZE
>=
(
sizeof
(
struct
hostent
)
+
sizeof
(
struct
hostent_data
)))
ret
=
gethostbyname_r
(
hostname
,
(
struct
hostent
*
)
buf
,
(
struct
hostent_data
*
)(
buf
+
sizeof
(
struct
hostent
)));
/* August 22nd, 2000: Albert Chin-A-Young brought an updated version
* that should work! September 20: Richard Prescott worked on the buffer
* size dilemma. */
ret
=
gethostbyname_r
(
hostname
,
(
struct
hostent
*
)
buf
,
(
struct
hostent_data
*
)(
buf
+
sizeof
(
struct
hostent
)));
else
ret
=
-
1
;
/* failure, too smallish buffer size */
/* result expected in h */
h
=
(
struct
hostent
*
)
buf
;
h_errnop
=
errno
;
/* we don't deal with this, but set it anyway */
...
...
@@ -166,11 +181,13 @@ struct hostent *GetHost(struct UrlData *data,
{
infof
(
data
,
"gethostbyname_r(2) failed for %s
\n
"
,
hostname
);
h
=
NULL
;
/* set return code to NULL */
free
(
buf
);
}
#else
else
{
if
((
h
=
gethostbyname
(
hostname
))
==
NULL
)
{
infof
(
data
,
"gethostbyname(2) failed for %s
\n
"
,
hostname
);
free
(
buf
);
}
#endif
}
...
...
This diff is collapsed.
Click to expand it.
lib/hostip.h
+
1
−
2
View file @
aa8a2fbd
...
...
@@ -40,7 +40,6 @@
* ------------------------------------------------------------
****************************************************************************/
extern
struct
hostent
*
GetHost
(
struct
UrlData
*
data
,
char
*
hostname
,
char
*
buf
,
int
buf_size
);
extern
char
*
MakeIP
(
unsigned
long
num
,
char
*
addr
,
int
addr_len
);
struct
hostent
*
GetHost
(
struct
UrlData
*
data
,
char
*
hostname
,
char
**
bufp
);
#endif
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