Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
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
Benjamin J. Thompson
Tor
Commits
72f775e1
Commit
72f775e1
authored
11 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Plain Diff
Merge branch 'bug9047' into maint-0.2.4
parents
25dddf7a
2338681e
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
changes/bug9047
+6
-0
6 additions, 0 deletions
changes/bug9047
src/common/compat.c
+15
-0
15 additions, 0 deletions
src/common/compat.c
src/common/compat.h
+1
-0
1 addition, 0 deletions
src/common/compat.h
src/or/microdesc.c
+13
-6
13 additions, 6 deletions
src/or/microdesc.c
with
35 additions
and
6 deletions
changes/bug9047
0 → 100644
+
6
−
0
View file @
72f775e1
o Minor bugfixes:
- If for some reason we fail to write a microdescriptor while
rebuilding the cache, do not let the annotations from that
microdescriptor linger in the cache file, and do not let the
microdescriptor stay recorded as present in its old location.
Fixes bug 9047; bugfix on 0.2.2.6-alpha.
This diff is collapsed.
Click to expand it.
src/common/compat.c
+
15
−
0
View file @
72f775e1
...
...
@@ -870,6 +870,9 @@ tor_lockfile_unlock(tor_lockfile_t *lockfile)
/** @{ */
/** Some old versions of Unix didn't define constants for these values,
* and instead expect you to say 0, 1, or 2. */
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
#ifndef SEEK_CUR
#define SEEK_CUR 1
#endif
...
...
@@ -900,6 +903,18 @@ tor_fd_seekend(int fd)
#endif
}
/** Move <b>fd</b> to position <b>pos</b> in the file. Return -1 on error, 0
* on success. */
int
tor_fd_setpos
(
int
fd
,
off_t
pos
)
{
#ifdef _WIN32
return
_lseek
(
fd
,
pos
,
SEEK_SET
)
<
0
?
-
1
:
0
;
#else
return
lseek
(
fd
,
pos
,
SEEK_SET
)
<
0
?
-
1
:
0
;
#endif
}
#undef DEBUG_SOCKET_COUNTING
#ifdef DEBUG_SOCKET_COUNTING
/** A bitarray of all fds that should be passed to tor_socket_close(). Only
...
...
This diff is collapsed.
Click to expand it.
src/common/compat.h
+
1
−
0
View file @
72f775e1
...
...
@@ -411,6 +411,7 @@ tor_lockfile_t *tor_lockfile_lock(const char *filename, int blocking,
void
tor_lockfile_unlock
(
tor_lockfile_t
*
lockfile
);
off_t
tor_fd_getpos
(
int
fd
);
int
tor_fd_setpos
(
int
fd
,
off_t
pos
);
int
tor_fd_seekend
(
int
fd
);
#ifdef _WIN32
...
...
This diff is collapsed.
Click to expand it.
src/or/microdesc.c
+
13
−
6
View file @
72f775e1
...
...
@@ -74,7 +74,7 @@ static ssize_t
dump_microdescriptor
(
int
fd
,
microdesc_t
*
md
,
size_t
*
annotation_len_out
)
{
ssize_t
r
=
0
;
size_t
written
;
s
size_t
written
;
if
(
md
->
body
==
NULL
)
{
*
annotation_len_out
=
0
;
return
0
;
...
...
@@ -99,10 +99,10 @@ dump_microdescriptor(int fd, microdesc_t *md, size_t *annotation_len_out)
md
->
off
=
tor_fd_getpos
(
fd
);
written
=
write_all
(
fd
,
md
->
body
,
md
->
bodylen
,
0
);
if
(
written
!=
md
->
bodylen
)
{
if
(
written
!=
(
ssize_t
)
md
->
bodylen
)
{
log_warn
(
LD_DIR
,
"Couldn't dump microdescriptor (wrote %l
u
out of %lu): %s"
,
(
unsigned
long
)
written
,
(
unsigned
long
)
md
->
bodylen
,
"Couldn't dump microdescriptor (wrote %l
d
out of %lu): %s"
,
(
long
)
written
,
(
unsigned
long
)
md
->
bodylen
,
strerror
(
errno
));
return
-
1
;
}
...
...
@@ -456,8 +456,15 @@ microdesc_cache_rebuild(microdesc_cache_t *cache, int force)
size
=
dump_microdescriptor
(
fd
,
md
,
&
annotation_len
);
if
(
size
<
0
)
{
/* XXX handle errors from dump_microdescriptor() */
/* log? return -1? die? coredump the universe? */
if
(
md
->
saved_location
!=
SAVED_IN_CACHE
)
tor_free
(
md
->
body
);
md
->
saved_location
=
SAVED_NOWHERE
;
md
->
off
=
0
;
md
->
bodylen
=
0
;
md
->
no_save
=
1
;
/* rewind, in case it was a partial write. */
tor_fd_setpos
(
fd
,
off
);
continue
;
}
tor_assert
(((
size_t
)
size
)
==
annotation_len
+
md
->
bodylen
);
...
...
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