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
Dragoș Haiduc
OpenLDAP
Commits
58d4afec
Commit
58d4afec
authored
17 years ago
by
Howard Chu
Browse files
Options
Downloads
Patches
Plain Diff
Sync with HEAD
parent
ee96d9c7
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
+12
-24
12 additions, 24 deletions
libraries/liblutil/utils.c
with
12 additions
and
24 deletions
libraries/liblutil/utils.c
+
12
−
24
View file @
58d4afec
...
...
@@ -663,6 +663,8 @@ 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
...
...
@@ -736,15 +738,16 @@ lutil_str2bin( struct berval *in, struct berval *out )
num
.
beg
=
num
.
bufsiz
-
1
;
num
.
len
=
0
;
if
(
pin
[
0
]
==
'-'
)
{
neg
=
1
;
neg
=
0xff
;
len
--
;
pin
++
;
}
#define DECMAX 8
/* 8 digits at a time */
if
(
len
>
sizeof
(
tmpbuf
))
{
tmp
=
ber_memalloc
(
len
);
/* tmp must be at least as large as outbuf */
if
(
out
->
bv_len
>
sizeof
(
tmpbuf
))
{
tmp
=
ber_memalloc
(
out
->
bv_len
);
}
else
{
tmp
=
tmpbuf
;
}
...
...
@@ -778,29 +781,14 @@ lutil_str2bin( struct berval *in, struct berval *out )
for
(
i
=
0
;
i
<
num
.
len
;
i
++
)
ptr
[
i
]
^=
0xff
;
/* Add 1, with carry */
i
--
;
j
=
1
;
for
(
;
i
>=
0
;
i
--
)
{
j
+=
ptr
[
i
];
ptr
[
i
]
=
j
&
0xff
;
j
>>=
8
;
if
(
!
j
)
break
;
}
/* If we overflowed and there's still room,
* set an explicit sign byte
*/
if
(
!
(
ptr
[
0
]
&
0x80
)
&&
num
.
beg
)
{
num
.
beg
--
;
num
.
len
++
;
num
.
buf
[
num
.
beg
]
=
0x80
;
}
}
else
if
((
num
.
buf
[
num
.
beg
]
&
0x80
)
&&
num
.
beg
)
{
/* positive int with high bit set, prepend 0 */
/* add 1, with carry - overflow handled below */
while
(
i
--
&&
!
(
ptr
[
i
]
=
(
ptr
[
i
]
+
1
)
&
0xff
))
;
}
/* Prepend sign byte if wrong sign bit */
if
((
num
.
buf
[
num
.
beg
]
^
neg
)
&
0x80
)
{
num
.
beg
--
;
num
.
len
++
;
num
.
buf
[
num
.
beg
]
=
0
;
num
.
buf
[
num
.
beg
]
=
neg
;
}
if
(
num
.
beg
)
AC_MEMCPY
(
num
.
buf
,
num
.
buf
+
num
.
beg
,
num
.
len
);
...
...
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