mail-cache-lookup.c revision adef31eb09ce4092968afc81680524ffb626b21e
baf6671fd3847865da9b64dc8f8be85d81304840Daniel Lezcano/* Copyright (c) 2003-2017 Dovecot authors, see the included COPYING file */
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcanoint mail_cache_get_record(struct mail_cache *cache, uint32_t offset,
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcano /* records are always 32-bit aligned */
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcano mail_cache_set_corrupted(cache, "invalid record offset");
49ee6cdcbf79d8b6fa617479ec8ab753ccca923dChristian Seiler /* we don't know yet how large the record is, so just guess */
8a67a2b2eaf28033962a432c214bd3303c29c54cdlezcano if (mail_cache_map(cache, offset, sizeof(*rec) + CACHE_PREFETCH,
6a85cf91247b7dd9c3faeddceca8dacb96d02cd6Stéphane Graber mail_cache_set_corrupted(cache, "record points outside file");
f080ffd7d656fbd9505a8e8eb52a05d61355c677Dwight Engen mail_cache_set_corrupted(cache, "invalid record size");
aa8d013ec5b09cd1cd904173d6234ef126eb2126Peter Simons /* larger than we guessed. map the rest of the record. */
7822022c4c72cee06905b540b89b653491d6f6b2Stéphane Graber if ((ret = mail_cache_map(cache, offset, rec->size, &data)) < 0)
8a67a2b2eaf28033962a432c214bd3303c29c54cdlezcano if (ret == 0) {
aa8d013ec5b09cd1cd904173d6234ef126eb2126Peter Simons mail_cache_set_corrupted(cache, "record points outside file");
5c320b769229d713e84b02ed6b7ae1309ac31dbbGuido Trotteruint32_t mail_cache_lookup_cur_offset(struct mail_index_view *view,
const void *data;
if (offset == 0)
i_unreached();
return offset;
int i, ret;
if (offset == 0)
return ret;
int ret;
if (ret <= 0) {
return FALSE;
return TRUE;
unsigned int field_idx;
unsigned int data_size;
int ret;
return ret;
int ret;
return ret;
unsigned int field)
const unsigned char *src;
unsigned char *dest;
int ret;
int ret;
if (ret <= 0)
return ret;
dest_buf);
return ret;
struct header_lookup_data {
const unsigned char *data;
struct header_lookup_line {
struct header_lookup_context {
void *data_dup;
if (lines[i] == 0)
lines_count = i;
if (data_size > 0) {
for (i = 0; i < lines_count; i++) {
int ret;
if (fields_count == 0)
for (i = 0; i < fields_count; i++)
for (i = 0; i < fields_count; i++) {
if (ret < 0)
for (i = 0; i <= max_field; i++) {
for (i = 0; i < count; i++) {
unsigned int fields_count)
int ret;
T_BEGIN {
&pool);
} T_END;
return ret;
static uint32_t
return seq;
if (offset != 0) {
return t_strdup_printf(
return t_strdup_printf(
if (seq == 0) {
return t_strdup_printf(
return t_strdup_printf(