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
David Barchiesi
OpenLDAP
Commits
994e07f2
Commit
994e07f2
authored
13 years ago
by
Hallvard Furuseth
Committed by
Quanah Gibson-Mount
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup back-ldif CRC code.
Handle interrupted write() again. Fix warnings/types. #ifdef LDAP_DEBUG.
parent
5e5852ee
No related branches found
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
servers/slapd/back-ldif/ldif.c
+19
-7
19 additions, 7 deletions
servers/slapd/back-ldif/ldif.c
with
19 additions
and
7 deletions
servers/slapd/back-ldif/ldif.c
+
19
−
7
View file @
994e07f2
...
...
@@ -58,6 +58,8 @@ struct ldif_info {
ldap_pvt_thread_rdwr_t
li_rdwr
;
/* no other I/O when writing */
};
static
int
write_data
(
int
fd
,
const
char
*
spew
,
int
len
,
int
*
save_errno
);
#ifdef _WIN32
#define mkdir(a,b) mkdir(a)
#define move_file(from, to) (!MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING))
...
...
@@ -331,7 +333,7 @@ ldif_tempname( const struct berval *dnpath )
* As used by zlib
*/
static
const
unsigned
in
t
crctab
[
256
]
=
{
static
const
ber_uint_
t
crctab
[
256
]
=
{
0x00000000L
,
0x77073096L
,
0xee0e612cL
,
0x990951baL
,
0x076dc419L
,
0x706af48fL
,
0xe963a535L
,
0x9e6495a3L
,
0x0edb8832L
,
0x79dcb8a4L
,
0xe0d5e91eL
,
0x97d2d988L
,
0x09b64c2bL
,
0x7eb17cbdL
,
0xe7b82d07L
,
...
...
@@ -388,9 +390,11 @@ static const unsigned int crctab[256] = {
#define CRC1 crc = crctab[(crc ^ *buf++) & 0xff] ^ (crc >> 8)
#define CRC8 CRC1; CRC1; CRC1; CRC1; CRC1; CRC1; CRC1; CRC1
unsigned
int
crc32
(
unsigned
char
*
buf
,
int
len
)
unsigned
int
crc32
(
const
void
*
vbuf
,
int
len
)
{
unsigned
int
crc
=
0xffffffff
;
const
unsigned
char
*
buf
=
vbuf
;
ber_uint_t
crc
=
0xffffffff
;
int
i
;
while
(
len
>
7
)
{
...
...
@@ -412,10 +416,10 @@ unsigned int crc32(unsigned char *buf, int len)
static
int
ldif_read_file
(
const
char
*
path
,
char
**
datap
)
{
int
rc
,
fd
,
len
;
int
rc
=
LDAP_SUCCESS
,
fd
,
len
;
int
res
=
-
1
;
/* 0:success, <0:error, >0:file too big/growing. */
struct
stat
st
;
char
*
data
=
NULL
,
*
ptr
;
char
*
data
=
NULL
,
*
ptr
=
NULL
;
if
(
datap
==
NULL
)
{
res
=
stat
(
path
,
&
st
);
...
...
@@ -448,9 +452,9 @@ ldif_read_file( const char *path, char **datap )
done:
if
(
res
==
0
)
{
#ifdef LDAP_DEBUG
Debug
(
LDAP_DEBUG_TRACE
,
"ldif_read_file: %s:
\"
%s
\"\n
"
,
datap
?
"read entry file"
:
"entry file exists"
,
path
,
0
);
rc
=
LDAP_SUCCESS
;
if
(
datap
)
{
len
=
ptr
-
data
;
ptr
=
strstr
(
data
,
"
\n
# CRC32"
);
...
...
@@ -473,6 +477,7 @@ ldif_read_file( const char *path, char **datap )
}
}
}
#endif
/* LDAP_DEBUG */
}
else
{
if
(
res
<
0
&&
errno
==
ENOENT
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"ldif_read_file: "
...
...
@@ -502,7 +507,14 @@ spew_file( int fd, const char *spew, int len, int *save_errno )
char
header
[
sizeof
(
HEADER
"# CRC32 12345678
\n
"
)];
sprintf
(
header
,
HEADER
"# CRC32 %08x
\n
"
,
crc32
(
spew
,
len
));
writeres
=
write
(
fd
,
header
,
sizeof
(
header
)
-
1
);
writeres
=
write_data
(
fd
,
header
,
sizeof
(
header
)
-
1
,
save_errno
);
return
writeres
<
0
?
writeres
:
write_data
(
fd
,
spew
,
len
,
save_errno
);
}
static
int
write_data
(
int
fd
,
const
char
*
spew
,
int
len
,
int
*
save_errno
)
{
int
writeres
=
0
;
while
(
len
>
0
)
{
writeres
=
write
(
fd
,
spew
,
len
);
if
(
writeres
==
-
1
)
{
...
...
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