Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simon
OpenLDAP
Commits
57d5aefe
Commit
57d5aefe
authored
May 20, 2020
by
Howard Chu
Browse files
ITS#9165 Fix pageedResults cookie printing
parent
005c870d
Changes
1
Hide whitespace changes
Inline
Side-by-side
clients/tools/common.c
View file @
57d5aefe
...
...
@@ -2072,12 +2072,13 @@ print_paged_results( LDAP *ld, LDAPControl *ctrl )
return
1
;
}
else
{
/* FIXME: check buffer overflow */
char
buf
[
BUFSIZ
],
*
ptr
=
buf
;
int
plen
;
if
(
estimate
>
0
)
{
ptr
+=
snprintf
(
ptr
,
sizeof
(
buf
)
-
(
ptr
-
buf
),
"estimate=%d"
,
estimate
);
plen
=
sprintf
(
buf
,
"estimate=%d cookie="
,
estimate
);
}
else
{
plen
=
sprintf
(
buf
,
"cookie="
);
}
if
(
pr_cookie
.
bv_len
>
0
)
{
...
...
@@ -2085,29 +2086,26 @@ print_paged_results( LDAP *ld, LDAPControl *ctrl )
bv
.
bv_len
=
LUTIL_BASE64_ENCODE_LEN
(
pr_cookie
.
bv_len
)
+
1
;
bv
.
bv_val
=
ber_memalloc
(
bv
.
bv_len
+
1
);
ptr
=
ber_memalloc
(
bv
.
bv_len
+
1
+
plen
);
bv
.
bv_val
=
ptr
+
plen
;
strcpy
(
ptr
,
buf
);
bv
.
bv_len
=
lutil_b64_ntop
(
(
unsigned
char
*
)
pr_cookie
.
bv_val
,
pr_cookie
.
bv_len
,
bv
.
bv_val
,
bv
.
bv_len
);
ptr
+=
snprintf
(
ptr
,
sizeof
(
buf
)
-
(
ptr
-
buf
),
"%scookie=%s"
,
ptr
==
buf
?
""
:
" "
,
bv
.
bv_val
);
ber_memfree
(
bv
.
bv_val
);
pr_morePagedResults
=
1
;
}
else
{
ptr
+=
snprintf
(
ptr
,
sizeof
(
buf
)
-
(
ptr
-
buf
),
"%scookie="
,
ptr
==
buf
?
""
:
" "
);
plen
+=
bv
.
bv_len
;
}
tool_write_ldif
(
ldif
?
LDIF_PUT_COMMENT
:
LDIF_PUT_VALUE
,
ldif
?
"pagedresults: "
:
"pagedresults"
,
buf
,
ptr
-
buf
);
ptr
,
plen
);
if
(
ptr
!=
buf
)
ber_memfree
(
ptr
);
}
return
0
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment