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
35fd1365
Commit
35fd1365
authored
21 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
simplied how create_hostcache_id() is used, and also its function somewhat
cleared up some ssize_t/size_t mixups
parent
f4930810
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/hostip.c
+9
-17
9 additions, 17 deletions
lib/hostip.c
with
9 additions
and
17 deletions
lib/hostip.c
+
9
−
17
View file @
35fd1365
...
...
@@ -156,30 +156,24 @@ static int _num_chars(int i)
/* Create a hostcache id */
static
char
*
create_hostcache_id
(
char
*
server
,
int
port
,
s
size_t
*
entry_len
)
create_hostcache_id
(
char
*
server
,
int
port
,
size_t
*
entry_len
)
{
char
*
id
=
NULL
;
/* Get the length of the new entry id */
*
entry_len
=
*
entry_len
+
/* Hostname length */
1
+
/* ':' seperator */
_num_chars
(
port
);
/* number of characters the port will take up */
*
entry_len
=
strlen
(
server
)
+
/* Hostname length */
1
+
/* ':' seperator */
_num_chars
(
port
);
/* number of characters the port will take up */
/* Allocate the new entry id */
id
=
malloc
(
*
entry_len
+
1
);
id
=
malloc
(
*
entry_len
+
1
);
/* 1 extra for the zero terminator */
if
(
!
id
)
return
NULL
;
/* Create the new entry */
/* If sprintf() doesn't return the entry length, that signals failure */
if
(
sprintf
(
id
,
"%s:%d"
,
server
,
port
)
!=
*
entry_len
)
{
/* Free the allocated id, set length to zero and return NULL */
*
entry_len
=
0
;
free
(
id
);
return
NULL
;
}
sprintf
(
id
,
"%s:%d"
,
server
,
port
);
return
id
;
return
id
;
/* return pointer to the string */
}
struct
hostcache_prune_data
{
...
...
@@ -256,12 +250,11 @@ cache_resolv_response(struct SessionHandle *data,
int
port
)
{
char
*
entry_id
;
s
size_t
entry_len
;
size_t
entry_len
;
struct
Curl_dns_entry
*
dns
;
time_t
now
;
/* Create an entry id, based upon the hostname and port */
entry_len
=
strlen
(
hostname
);
entry_id
=
create_hostcache_id
(
hostname
,
port
,
&
entry_len
);
/* If we can't create the entry id, fail */
if
(
!
entry_id
)
...
...
@@ -315,7 +308,7 @@ int Curl_resolv(struct connectdata *conn,
{
char
*
entry_id
=
NULL
;
struct
Curl_dns_entry
*
dns
=
NULL
;
s
size_t
entry_len
;
size_t
entry_len
;
int
wait
;
struct
SessionHandle
*
data
=
conn
->
data
;
CURLcode
result
;
...
...
@@ -335,7 +328,6 @@ int Curl_resolv(struct connectdata *conn,
#endif
/* Create an entry id, based upon the hostname and port */
entry_len
=
strlen
(
hostname
);
entry_id
=
create_hostcache_id
(
hostname
,
port
,
&
entry_len
);
/* If we can't create the entry id, fail */
if
(
!
entry_id
)
...
...
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