timed out. Bugfix on 0.1.2.1-alpha; our CLEAR debugging code
had been suppressing the bug since 0.1.2.10-alpha. Partial fix
for bug 929.
+ - Do not assume that a stack-allocated character array will be
+ 64-bit aligned on platforms that demand that uint64_t access is
+ aligned. Possible fix for bug 604.
o Minor features:
- On Linux, use the prctl call to re-enable core dumps when the user
memcpy(&v,cp,4);
return v;
}
+/**
+ * Read a 32-bit value beginning at <b>cp</b>. Equivalent to
+ * *(uint32_t*)(cp), but will not cause segfaults on platforms that forbid
+ * unaligned memory access.
+ */
+uint64_t
+get_uint64(const char *cp)
+{
+ uint64_t v;
+ memcpy(&v,cp,8);
+ return v;
+}
+
/**
* Set a 16-bit value beginning at <b>cp</b> to <b>v</b>. Equivalent to
- * *(uint16_t)(cp) = v, but will not cause segfaults on platforms that forbid
+ * *(uint16_t*)(cp) = v, but will not cause segfaults on platforms that forbid
* unaligned memory access. */
void
set_uint16(char *cp, uint16_t v)
}
/**
* Set a 32-bit value beginning at <b>cp</b> to <b>v</b>. Equivalent to
- * *(uint32_t)(cp) = v, but will not cause segfaults on platforms that forbid
+ * *(uint32_t*)(cp) = v, but will not cause segfaults on platforms that forbid
* unaligned memory access. */
void
set_uint32(char *cp, uint32_t v)
{
memcpy(cp,&v,4);
}
+/**
+ * Set a 64-bit value beginning at <b>cp</b> to <b>v</b>. Equivalent to
+ * *(uint64_t*)(cp) = v, but will not cause segfaults on platforms that forbid
+ * unaligned memory access. */
+void
+set_uint64(char *cp, uint64_t v)
+{
+ memcpy(cp,&v,8);
+}
/**
* Rename the file <b>from</b> to the file <b>to</b>. On unix, this is
uint16_t get_uint16(const char *cp) ATTR_PURE ATTR_NONNULL((1));
uint32_t get_uint32(const char *cp) ATTR_PURE ATTR_NONNULL((1));
+uint64_t get_uint64(const char *cp) ATTR_PURE ATTR_NONNULL((1));
void set_uint16(char *cp, uint16_t v) ATTR_NONNULL((1));
void set_uint32(char *cp, uint32_t v) ATTR_NONNULL((1));
+void set_uint64(char *cp, uint64_t v) ATTR_NONNULL((1));
/* These uint8 variants are defined to make the code more uniform. */
#define get_uint8(cp) (*(const uint8_t*)(cp))
tag_pack(char *tag, uint64_t conn_id, circid_t circ_id)
{
/*XXXX RETHINK THIS WHOLE MESS !!!! !NM NM NM NM*/
- *(uint64_t *)tag = conn_id;
- *(uint16_t *)(tag+8) = circ_id;
+ set_uint64(tag, conn_id);
+ set_uint16(tag+8, circ_id);
}
/** Unpack <b>tag</b> into addr, port, and circ_id.
static void
tag_unpack(const char *tag, uint64_t *conn_id, circid_t *circ_id)
{
- *conn_id = *(const uint64_t *)tag;
- *circ_id = *(const uint16_t *)(tag+8);
+ *conn_id = get_uint64(tag);
+ *circ_id = get_uint16(tag+8);
}
/** Called when the onion key has changed and we need to spawn new