#include "codeconv.h"
#include "timing.h"
#include "tags.h"
+#include "prefs_common.h"
#ifdef HAVE_FWRITE_UNLOCKED
#define SC_FWRITE fwrite_unlocked
n = swapping ? bswap_32(idata) : (idata);\
}
-#define GET_CACHE_DATA_INT(n) \
-{ \
- n = (swapping ? (MMAP_TO_GUINT32_SWAPPED(walk_data)):(MMAP_TO_GUINT32(walk_data))); \
- walk_data += 4; rem_len -= 4; \
+#define GET_CACHE_DATA_INT(n) \
+{ \
+ if (rem_len < 4) { \
+ g_print("error at rem_len:%d\n", rem_len); \
+ error = TRUE; \
+ goto bail_err; \
+ } \
+ n = (swapping ? (MMAP_TO_GUINT32_SWAPPED(walk_data)):(MMAP_TO_GUINT32(walk_data))); \
+ walk_data += 4; rem_len -= 4; \
}
#define GET_CACHE_DATA(data, total_len) \
{ \
GET_CACHE_DATA_INT(tmp_len); \
+ if (rem_len < tmp_len) { \
+ g_print("error at rem_len:%d (tmp_len %d)\n", rem_len, tmp_len); \
+ error = TRUE; \
+ goto bail_err; \
+ } \
if ((tmp_len = msgcache_get_cache_data_str(walk_data, &data, tmp_len, conv)) < 0) { \
g_print("error at rem_len:%d\n", rem_len);\
procmsg_msginfo_free(msginfo); \
gint map_len = -1;
char *cache_data = NULL;
struct stat st;
-
+ gboolean error;
+
swapping = TRUE;
/* In case we can't open the mark file with MARK_VERSION, check if we can open it with the
}
}
}
+bail_err:
fclose(fp);
}
gint map_len = -1;
char *cache_data = NULL;
struct stat st;
-
+ gboolean error = FALSE;
+
swapping = TRUE;
/* In case we can't open the mark file with MARK_VERSION, check if we can open it with the
}
}
}
+bail_err:
fclose(fp);
}
write_fps.error |= (fflush(write_fps.tags_fp) != 0);
/* sync to filesystem */
- if (write_fps.cache_fp)
+ if (prefs_common.flush_metadata && write_fps.cache_fp)
write_fps.error |= (fsync(fileno(write_fps.cache_fp)) != 0);
- if (write_fps.mark_fp)
+ if (prefs_common.flush_metadata && write_fps.mark_fp)
write_fps.error |= (fsync(fileno(write_fps.mark_fp)) != 0);
- if (write_fps.tags_fp)
+ if (prefs_common.flush_metadata && write_fps.tags_fp)
write_fps.error |= (fsync(fileno(write_fps.tags_fp)) != 0);
/* close files */