Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
James Lowden
OpenLDAP
Commits
dcd74439
Commit
dcd74439
authored
13 years ago
by
Howard Chu
Committed by
Quanah Gibson-Mount
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ITS#7174 lutil_str2bin: can't modify input strings
parent
a8724191
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
libraries/liblutil/utils.c
+11
-13
11 additions, 13 deletions
libraries/liblutil/utils.c
with
11 additions
and
13 deletions
libraries/liblutil/utils.c
+
11
−
13
View file @
dcd74439
...
...
@@ -714,8 +714,6 @@ scale( int new, lutil_int_decnum *prev, unsigned char *tmp )
* Output buffer must be provided, bv_len must indicate buffer size
* Hex input can be "0x1234" or "'1234'H"
*
* Temporarily modifies the input string.
*
* Note: High bit of binary form is always the sign bit. If the number
* is supposed to be positive but has the high bit set, a zero byte
* is prepended. It is assumed that this has already been handled on
...
...
@@ -724,7 +722,7 @@ scale( int new, lutil_int_decnum *prev, unsigned char *tmp )
int
lutil_str2bin
(
struct
berval
*
in
,
struct
berval
*
out
,
void
*
ctx
)
{
char
*
pin
,
*
pout
,
ctmp
;
char
*
pin
,
*
pout
;
char
*
end
;
int
i
,
chunk
,
len
,
rc
=
0
,
hex
=
0
;
if
(
!
out
||
!
out
->
bv_val
||
out
->
bv_len
<
in
->
bv_len
)
...
...
@@ -749,6 +747,8 @@ lutil_str2bin( struct berval *in, struct berval *out, void *ctx )
if
(
hex
)
{
#define HEXMAX (2 * sizeof(long))
unsigned
long
l
;
char
tbuf
[
HEXMAX
+
1
];
/* Convert a longword at a time, but handle leading
* odd bytes first
*/
...
...
@@ -758,11 +758,10 @@ lutil_str2bin( struct berval *in, struct berval *out, void *ctx )
while
(
len
)
{
int
ochunk
;
ctmp
=
pin
[
chunk
]
;
pin
[
chunk
]
=
'\0'
;
memcpy
(
tbuf
,
pin
,
chunk
)
;
tbuf
[
chunk
]
=
'\0'
;
errno
=
0
;
l
=
strtoul
(
pin
,
&
end
,
16
);
pin
[
chunk
]
=
ctmp
;
l
=
strtoul
(
tbuf
,
&
end
,
16
);
if
(
errno
)
return
-
1
;
ochunk
=
(
chunk
+
1
)
/
2
;
...
...
@@ -778,10 +777,12 @@ lutil_str2bin( struct berval *in, struct berval *out, void *ctx )
out
->
bv_len
=
pout
-
out
->
bv_val
;
}
else
{
/* Decimal */
#define DECMAX 8
/* 8 digits at a time */
char
tmpbuf
[
64
],
*
tmp
;
lutil_int_decnum
num
;
int
neg
=
0
;
long
l
;
char
tbuf
[
DECMAX
+
1
];
len
=
in
->
bv_len
;
pin
=
in
->
bv_val
;
...
...
@@ -795,8 +796,6 @@ lutil_str2bin( struct berval *in, struct berval *out, void *ctx )
pin
++
;
}
#define DECMAX 8
/* 8 digits at a time */
/* tmp must be at least as large as outbuf */
if
(
out
->
bv_len
>
sizeof
(
tmpbuf
))
{
tmp
=
ber_memalloc_x
(
out
->
bv_len
,
ctx
);
...
...
@@ -808,11 +807,10 @@ lutil_str2bin( struct berval *in, struct berval *out, void *ctx )
chunk
=
DECMAX
;
while
(
len
)
{
ctmp
=
pin
[
chunk
]
;
pin
[
chunk
]
=
'\0'
;
memcpy
(
tbuf
,
pin
,
chunk
)
;
tbuf
[
chunk
]
=
'\0'
;
errno
=
0
;
l
=
strtol
(
pin
,
&
end
,
10
);
pin
[
chunk
]
=
ctmp
;
l
=
strtol
(
tbuf
,
&
end
,
10
);
if
(
errno
)
{
rc
=
-
1
;
goto
decfail
;
...
...
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