Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
lyskom-server-ceder-1616-generations-topgit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Per Cederqvist
lyskom-server-ceder-1616-generations-topgit
Commits
d9bf72de
Commit
d9bf72de
authored
33 years ago
by
Per Cederqvist
Browse files
Options
Downloads
Patches
Plain Diff
Fixed included files.
Fixed possible memory leak in prot_a_parse_string. Needs more work.
parent
53612c10
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/server/prot-a-parse.c
+28
-17
28 additions, 17 deletions
src/server/prot-a-parse.c
with
28 additions
and
17 deletions
src/server/prot-a-parse.c
+
28
−
17
View file @
d9bf72de
...
...
@@ -7,8 +7,8 @@
#include
<setjmp.h>
#include
<string.h>
#include
<kom-types.h>
#include
"s-string.h"
#include
<kom-types.h>
#include
"lyskomd.h"
#include
"com.h"
#include
"connections.h"
...
...
@@ -18,6 +18,7 @@
#include
"minmax.h"
#include
"prot-a.h"
#include
"config.h"
#include
"log.h"
long
prot_a_parse_long
(
Connection
*
client
)
...
...
@@ -83,27 +84,30 @@ prot_a_parse_conf_type(Connection *client,
/*
* Parse a string. At most 'maxlen' characters are allowed. If the
* client sends a longer string only the first 'maxlen+1' characters
* are read. The following characters are discarded.
* are read. Any remaining characters are discarded.
*/
/*
* +++ This needs cleaning up. See comments in and above mux_parse_string.
*/
void
prot_a_parse_string
(
Connection
*
client
,
String
*
result
,
int
maxlen
)
String
*
result
,
int
maxlen
)
{
String_size
hptr
;
/* Pointer to 'H' */
String_size
client_len
;
/* The len the client is sending. */
String_size
truncated_len
;
/* How much the server will receive. */
String_size
to_skip
;
String
tmp
;
static
u_long
err_cnt
=
0
;
switch
(
client
->
string_parse_pos
)
{
case
0
:
/* Get number and discard trailing 'H' */
result
->
len
=
s_strtol
(
s_fsubstr
(
client
->
unparsed
,
client
->
first_to_parse
,
END_OF_STRING
),
&
hptr
,
PROTOCOL_NUMBER_BASE
);
client_
len
=
s_strtol
(
s_fsubstr
(
client
->
unparsed
,
client
->
first_to_parse
,
END_OF_STRING
),
&
hptr
,
PROTOCOL_NUMBER_BASE
);
if
(
hptr
==
-
1
||
client
->
first_to_parse
+
hptr
...
...
@@ -130,8 +134,7 @@ prot_a_parse_string(Connection *client,
/* Check that the entire string is transmitted. */
/* (Don't care about the trailing part that will be skipped if the
* string is longer than maxlen) */
truncated_len
=
min
(
maxlen
+
1
,
result
->
len
);
client_len
=
result
->
len
;
truncated_len
=
min
(
maxlen
+
1
,
client_len
);
if
(
client
->
first_to_parse
+
truncated_len
>
s_strlen
(
client
->
unparsed
)
)
...
...
@@ -139,12 +142,20 @@ prot_a_parse_string(Connection *client,
longjmp
(
parse_env
,
ISC_MSG_INCOMPLETE
);
}
result
->
string
=
client
->
unparsed
.
string
+
client
->
first_to_parse
;
result
->
len
=
truncated_len
;
tmp
=
EMPTY_STRING
;
s_strcpy
(
&
tmp
,
*
result
);
/* Copy the string. */
*
result
=
tmp
;
result
->
len
=
client_len
;
if
(
(
result
->
len
!=
0
||
result
->
string
!=
NULL
)
&&
err_cnt
++
<
20
)
{
log
(
"prot_a_parse_string(): result->len == %lu, "
"result->string == %lu. This memory will not be free()'d.
\n
"
,
(
u_long
)
result
->
len
,
(
u_long
)
result
->
string
);
*
result
=
EMPTY_STRING
;
if
(
err_cnt
==
20
)
log
(
"Won't log the above warning no more."
);
}
s_mem_crea_str
(
result
,
client
->
unparsed
.
string
+
client
->
first_to_parse
,
truncated_len
);
result
->
len
=
client_len
;
/* Ugly! +++ */
client
->
first_to_parse
+=
truncated_len
;
client
->
string_parse_pos
=
2
;
...
...
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