diff options
author | Ladar Levison <ladar@lavabit.com> | 2018-11-30 15:34:51 +0300 |
---|---|---|
committer | Ladar Levison <ladar@lavabit.com> | 2018-11-30 15:34:51 +0300 |
commit | 83ca3a582e507a1111f281fde3b9b1154e89714a (patch) | |
tree | c39ac2361a675d939b11a5ddd30fd5ee2e6c6d28 /src | |
parent | a2a48513e8ea8ad5401ed1c59a61fdfec71c9e41 (diff) |
Added the packed attribute to structs nested inside already packed structs.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/buckets/buckets.h | 6 | ||||
-rw-r--r-- | src/core/indexes/indexes.h | 2 | ||||
-rw-r--r-- | src/core/parsers/formats/formats.h | 2 | ||||
-rw-r--r-- | src/network/meta.h | 14 | ||||
-rw-r--r-- | src/network/network.h | 12 | ||||
-rw-r--r-- | src/network/sessions.h | 14 | ||||
-rw-r--r-- | src/objects/messages/messages.h | 10 | ||||
-rw-r--r-- | src/providers/compress/compress.h | 4 | ||||
-rw-r--r-- | src/providers/consumers/consumers.h | 2 | ||||
-rw-r--r-- | src/providers/cryptography/cryptography.h | 4 | ||||
-rw-r--r-- | src/providers/prime/prime.h | 22 | ||||
-rw-r--r-- | src/providers/providers.h | 2 | ||||
-rw-r--r-- | src/providers/storage/storage.h | 22 |
13 files changed, 58 insertions, 58 deletions
diff --git a/src/core/buckets/buckets.h b/src/core/buckets/buckets.h index dd4e0d0d..df485dc6 100644 --- a/src/core/buckets/buckets.h +++ b/src/core/buckets/buckets.h @@ -43,19 +43,19 @@ typedef enum { typedef M_POOL_STATUS status_t; -typedef struct { +typedef struct __attribute__ ((packed)) { void *data; struct stacker_node_t *next; } stacker_node_t; -typedef struct { +typedef struct __attribute__ ((packed)) { uint64_t items; pthread_mutex_t mutex; stacker_node_t *list, *last; void (*free_function)(void *data); } stacker_t; -typedef struct { +typedef struct __attribute__ ((packed)) { uint32_t count; /* Number of objects allocated. */ uint32_t timeout; /* How long to wait for an object before timing out. Zero is forever. */ uint64_t failures; /* Tracks the number of times a thread was forced to return empty handed. */ diff --git a/src/core/indexes/indexes.h b/src/core/indexes/indexes.h index cfba07e9..8f955e1c 100644 --- a/src/core/indexes/indexes.h +++ b/src/core/indexes/indexes.h @@ -31,7 +31,7 @@ typedef enum { */ #define MAGMA_INDEX_OPTION (M_INX_INDEX_LOCK) -typedef struct { +typedef struct __attribute__ ((packed)) { // Data and record count void *index, *last; diff --git a/src/core/parsers/formats/formats.h b/src/core/parsers/formats/formats.h index 4b7f63ab..ceb106be 100644 --- a/src/core/parsers/formats/formats.h +++ b/src/core/parsers/formats/formats.h @@ -12,7 +12,7 @@ typedef struct { MAGMA_INDEX options; - struct { + struct __attribute__ ((packed)) { char comment, value, line; } tokens; inx_t *pairs; diff --git a/src/network/meta.h b/src/network/meta.h index 1288d264..ed498600 100644 --- a/src/network/meta.h +++ b/src/network/meta.h @@ -77,7 +77,7 @@ typedef struct __attribute__ ((packed)) { stringer_t *display, *address; } meta_alias_t; -typedef struct { +typedef struct __attribute__ ((packed)) { size_t size; array_t *tags; chr_t server[33]; @@ -85,14 +85,14 @@ typedef struct { uint64_t messagenum, foldernum, sequencenum, signum, sigkey, created; } meta_message_t; -typedef struct { +typedef struct __attribute__ ((packed)) { chr_t name[128]; // Even though we limit folder names to 16 characters, with modified UTF-7 escaping, the string could be longer. uint32_t order; uint64_t parent, foldernum; } meta_folder_t; // All of a user's information is stored using this structure. -typedef struct { +typedef struct __attribute__ ((packed)) { uint64_t usernum; pthread_rwlock_t lock; @@ -101,21 +101,21 @@ typedef struct { inx_t *aliases, *messages, *message_folders, *folders, *contacts; // The symmetric realm keys. - struct { + struct __attribute__ ((packed)) { stringer_t *mail; } realm; // The user signet and private keys. - struct { + struct __attribute__ ((packed)) { stringer_t *key; stringer_t *signet; } prime; - struct { + struct __attribute__ ((packed)) { uint64_t user, messages, folders, contacts, aliases; } serials; - struct { + struct __attribute__ ((packed)) { time_t stamp; uint64_t smtp, pop, imap, web, generic; pthread_mutex_t lock; diff --git a/src/network/network.h b/src/network/network.h index 36c5839c..112bd2b4 100644 --- a/src/network/network.h +++ b/src/network/network.h @@ -23,14 +23,14 @@ enum { REVERSE_COMPLETE = 2 }; -typedef struct { +typedef struct __attribute__ ((packed)) { char *string; size_t length; void *function; } command_t; // Setup the structure of variables used to relay and bounce messages. -typedef struct { +typedef struct __attribute__ ((packed)) { ip_t *ip; /* The remote host address information. */ uint32_t port; /* The remote host port information. */ void *tls; /* The TLS connection object. */ @@ -40,7 +40,7 @@ typedef struct { stringer_t *buffer; /* The connection buffer. */ } client_t; -typedef struct { +typedef struct __attribute__ ((packed)) { union { pop_session_t pop; imap_session_t imap; @@ -49,19 +49,19 @@ typedef struct { http_session_t http; }; - struct { + struct __attribute__ ((packed)) { uint32_t spins; uint32_t violations; } protocol; - struct { + struct __attribute__ ((packed)) { void *tls; /* The TLS connection object. */ int sockd; /* The socket connection. */ int status; /* Track whether the last network operation generated an error. */ placer_t line; /* The current line being processed. */ stringer_t *buffer; /* The connection buffer. */ - struct { + struct __attribute__ ((packed)) { ip_t *ip; int_t status; stringer_t *domain; diff --git a/src/network/sessions.h b/src/network/sessions.h index baa876bc..f081e897 100644 --- a/src/network/sessions.h +++ b/src/network/sessions.h @@ -14,26 +14,26 @@ enum { SESSION_STATE_AUTHENTICATED = 1 }; -typedef struct { +typedef struct __attribute__ ((packed)) { uint64_t attach_id; /* The unique attachment id. */ stringer_t *filename; /* The local filename of the submitted attachment. */ stringer_t *filedata; /* The raw data of the attached file. */ } attachment_t; -typedef struct { +typedef struct __attribute__ ((packed)) { uint64_t comp_id; /* The composition ID, returned in response to a messages.compose request. */ uint64_t attached; /* The attachment # counter. */ inx_t *attachments; /* A list of the files that have been submitted for attachment to this composition. */ } composition_t; -typedef struct { +typedef struct __attribute__ ((packed)) { int_t state; meta_user_t *user; inx_t *compositions; uint64_t composed; - struct { + struct __attribute__ ((packed)) { bool_t secure; bool_t httponly; stringer_t *host; @@ -42,7 +42,7 @@ typedef struct { } request; // The warden is responsible for locating a session in memory and ensuring that only legitimate requests are allowed access. - struct { + struct __attribute__ ((packed)) { ip_t ip; /* The owner's IP address. */ uint64_t key; /* Randomly generated number used to authenticate a request. */ uint64_t host; /* The cluster node that created and owns a particular session. */ @@ -52,12 +52,12 @@ typedef struct { stringer_t *token; /* The encrypted token used to retrieve this session during future requests. */ } warden; - struct { + struct __attribute__ ((packed)) { time_t stamp; uint64_t web; } refs; - struct { + struct __attribute__ ((packed)) { time_t stamp; bool_t trigger; } refresh; diff --git a/src/objects/messages/messages.h b/src/objects/messages/messages.h index ad6fbbce..40ab4c0a 100644 --- a/src/objects/messages/messages.h +++ b/src/objects/messages/messages.h @@ -67,23 +67,23 @@ enum { typedef struct __attribute__ ((packed)) { - struct { + struct __attribute__ ((packed)) { uint64_t num; /* Unique message number. */ uint64_t created; /* When the message record was created. */ uint64_t sequence; /* Position in the folder. */ } message; - struct { + struct __attribute__ ((packed)) { array_t *tags; /* Any message tags. */ uint32_t flags; /* System flags. */ } status; - struct { + struct { __attribute__ ((packed)) uint64_t num; /* Junk filter signature number. */ uint64_t key; /* Junk filter access key. */ } signature; - struct { + struct __attribute__ ((packed)) { stringer_t *server; /* The storage node. */ stringer_t *header; /* The message header data. */ stringer_t *body; /* The message body data. */ @@ -110,7 +110,7 @@ typedef struct __attribute__ ((packed)) { uint8_t magic2; // second magic byte: 0x76 uint8_t reserved; uint8_t flags; -} message_header_t; +} message_header_t; /// messages.c message_t * message_alloc(uint64_t messagenum, uint64_t created, uint64_t signature, uint64_t key, uint64_t flags, stringer_t *server, size_t size); diff --git a/src/providers/compress/compress.h b/src/providers/compress/compress.h index 5eaf71c5..b8224bae 100644 --- a/src/providers/compress/compress.h +++ b/src/providers/compress/compress.h @@ -18,12 +18,12 @@ typedef struct __attribute__ ((packed)) { uint8_t engine; - struct { + struct __attribute__ ((packed)) { uint64_t original; uint64_t compressed; } length; - struct { + struct __attribute__ ((packed)) { uint64_t original; uint64_t compressed; } hash; diff --git a/src/providers/consumers/consumers.h b/src/providers/consumers/consumers.h index b2c10b69..8b43973b 100644 --- a/src/providers/consumers/consumers.h +++ b/src/providers/consumers/consumers.h @@ -9,7 +9,7 @@ #define MAGMA_PROVIDERS_CONSUMERS_H -typedef struct { +typedef struct __attribute__ ((packed)) { size_t position; stringer_t *data; } serialization_t; diff --git a/src/providers/cryptography/cryptography.h b/src/providers/cryptography/cryptography.h index f1a7333d..961fd05d 100644 --- a/src/providers/cryptography/cryptography.h +++ b/src/providers/cryptography/cryptography.h @@ -45,13 +45,13 @@ typedef struct __attribute__ ((packed)) { uint32_t engine; - struct { + struct __attribute__ ((packed)) { uint64_t vector; uint64_t original; uint64_t scrambled; } length; - struct { + struct __attribute__ ((packed)) { // uint64_t original; using a cipher that supports creating an hmac. uint32_t scrambled; } hash; diff --git a/src/providers/prime/prime.h b/src/providers/prime/prime.h index 6a07869b..4e1f340e 100644 --- a/src/providers/prime/prime.h +++ b/src/providers/prime/prime.h @@ -206,7 +206,7 @@ typedef struct __attribute__ ((packed)) { typedef struct __attribute__ ((packed)) { ed25519_key_t *signing; /**< User signing key, field 1. */ secp256k1_key_t *encryption; /**< User encryption key, field 2. */ - struct { + struct __attribute__ ((packed)) { stringer_t *custody; /**< User chain of custody signature, field 4. */ stringer_t *user; /**< User signature, field 5. */ stringer_t *org; /**< Organizational signature, field 6. */ @@ -262,11 +262,11 @@ typedef struct __attribute__ ((packed)) { * @typedef prime_ephemeral_chunk_t */ typedef struct __attribute__ ((packed)) { - struct { + struct __attribute__ ((packed)) { uint8_t type; /**< Chunk type, which curently, should always be 1. */ uint32_t length; /**< Payload length. Currently, this should only be 35 or 69. */ } header; - struct { + struct __attribute__ ((packed)) { ed25519_key_t *signing; secp256k1_key_t *encryption; } keys; @@ -277,7 +277,7 @@ typedef struct __attribute__ ((packed)) { * @typedef prime_encrypted_chunk_t */ typedef struct __attribute__ ((packed)) prime_encrypted_chunk_t { - struct { + struct __attribute__ ((packed)) { uint8_t type; /**< Chunk type, 1 through 255. */ uint32_t length; /**< Payload length, must be divisible by 16 and less than 2^24 - 1. */ } header; @@ -309,22 +309,22 @@ typedef struct __attribute__ ((packed)) { prime_chunk_keys_t keys; prime_chunk_keks_t keks; - struct { + struct __attribute__ ((packed)) { prime_ephemeral_chunk_t *ephemeral; prime_encrypted_chunk_t *origin; prime_encrypted_chunk_t *destination; } envelope; - struct { + struct __attribute__ ((packed)) { prime_encrypted_chunk_t *common; prime_encrypted_chunk_t *headers; } metadata; - struct { + struct __attribute__ ((packed)) { prime_encrypted_chunk_t *body; } content; - struct { + struct __attribute__ ((packed)) { stringer_t *tree; stringer_t *user; stringer_t *org; @@ -340,19 +340,19 @@ typedef struct __attribute__ ((packed)) { typedef struct __attribute__ ((packed)) { prime_type_t type; prime_flags_t flags; - struct { + struct __attribute__ ((packed)) { union { prime_org_key_t *org; prime_user_key_t *user; }; } key; - struct { + struct __attribute__ ((packed)) { union { prime_org_signet_t *org; prime_user_signet_t *user; }; } signet; - struct { + struct __attribute__ ((packed)) { union { prime_message_t *naked; prime_message_t *native; diff --git a/src/providers/providers.h b/src/providers/providers.h index f258b70c..c94d5fe4 100644 --- a/src/providers/providers.h +++ b/src/providers/providers.h @@ -8,7 +8,7 @@ #ifndef MAGMA_PROVIDERS_H #define MAGMA_PROVIDERS_H -typedef struct { +typedef struct __attribute__ ((packed)) { const chr_t *name; void **pointer; } symbol_t; diff --git a/src/providers/storage/storage.h b/src/providers/storage/storage.h index 80309546..0d32ca84 100644 --- a/src/providers/storage/storage.h +++ b/src/providers/storage/storage.h @@ -30,7 +30,7 @@ typedef struct __attribute__ ((packed)) { uint8_t rec; /*!< The length of the record data. */ uint64_t flags; /*!< A collection of bit mask flags to indicate whether the object was compressed, encrypted, or replicated. */ - struct { + struct __attribute__ ((packed)) { uint64_t tnum; /*!< Which local storage tank was used to store the object. */ uint64_t unum; /*!< The user number of the object owner. */ uint64_t onum; /*!< The object number. */ @@ -38,7 +38,7 @@ typedef struct __attribute__ ((packed)) { uint64_t created; /*!< Time stamp taken when the object is stored. */ } meta; - struct { + struct __attribute__ ((packed)) { uint64_t length; /*!< The full length of the original data. */ uint64_t compressed; /*!< The compressed length of the data, if applicable. */ uint64_t encrypted; /*!< The length of the encrypted data block, if applicable. */ @@ -50,20 +50,20 @@ typedef struct __attribute__ ((packed)) { uint8_t ver; /*!< Number indicating the entry version, which also tells us the layout of the data. */ - struct { - uint64_t tnum; /*!< Which local storage tank was used to store the object. */ - uint64_t unum; /*!< The user number of the object owner. */ - uint64_t onum; /*!< The object number. */ - uint64_t snum; /*!< The serial number. Starts at zero, and increments for each update. */ - uint64_t stamp; /*!< Time stamp taken when the object is stored. */ - } meta; + struct __attribute__ ((packed)) { + uint64_t tnum; /*!< Which local storage tank was used to store the object. */ + uint64_t unum; /*!< The user number of the object owner. */ + uint64_t onum; /*!< The object number. */ + uint64_t snum; /*!< The serial number. Starts at zero, and increments for each update. */ + uint64_t stamp; /*!< Time stamp taken when the object is stored. */ + } meta; - struct { + struct __attribute__ ((packed)) { uint64_t created; /*!< When the object was first created. */ uint64_t updated; /*!< When the object was last updated. */ uint64_t deleted; /*!< When the object was flagged for deletion. */ uint64_t expiration; /*!< When archived/deleted objects can be permanently purged. */ - } stamps; + } stamps; } entry_t; |