summaryrefslogtreecommitdiff
path: root/src/common/compat.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-06-13 12:29:01 -0400
committerNick Mathewson <nickm@torproject.org>2013-06-13 12:29:01 -0400
commitcaa0d15c4902a8d376a2a79bfbfdb21bf047366a (patch)
treed6883b87bcba5019e828f34272965b879f191101 /src/common/compat.c
parent25dddf7a8f30699242b52fce115f29401f63ee9c (diff)
downloadtor-caa0d15c4902a8d376a2a79bfbfdb21bf047366a.tar.gz
tor-caa0d15c4902a8d376a2a79bfbfdb21bf047366a.zip
If we write the annotation but not the microdescriptor, rewind.
This fixes bug 9047 (and some parts of 9031, 8922, 8883 that weren't fixed in 8822). Bugfix on 0.2.2.6-alpha.
Diffstat (limited to 'src/common/compat.c')
-rw-r--r--src/common/compat.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index c97a4545c9..24b44fb055 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -900,6 +900,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