diff src/libpst.c @ 340:0f3185217313

Daniel Gryniewicz found buffer overrun in LIST_COPY_TIME
author Carl Byington <carl@five-ten-sg.com>
date Fri, 27 Dec 2013 08:27:47 -0800
parents c507af52515a
children c638905665bc
line wrap: on
line diff
--- a/src/libpst.c	Sun Sep 22 18:02:00 2013 -0700
+++ b/src/libpst.c	Fri Dec 27 08:27:47 2013 -0800
@@ -2068,11 +2068,13 @@
         DEBUG_WARN(("src not 0x40 for filetime dst\n"));                    \
         DEBUG_HEXDUMP(list->elements[x]->data, list->elements[x]->size);    \
     }                                                                       \
-    targ = (FILETIME*) pst_realloc(targ, sizeof(FILETIME));                 \
-    memcpy(targ, list->elements[x]->data, list->elements[x]->size);         \
-    LE32_CPU(targ->dwLowDateTime);                                          \
-    LE32_CPU(targ->dwHighDateTime);                                         \
-    DEBUG_INFO((label" - %s", pst_fileTimeToAscii(targ, time_buffer)));     \
+    else {                                                                  \
+        targ = (FILETIME*) pst_realloc(targ, sizeof(FILETIME));             \
+        memcpy(targ, list->elements[x]->data, min(sizeof(FILETIME), list->elements[x]->size)); \
+        LE32_CPU(targ->dwLowDateTime);                                      \
+        LE32_CPU(targ->dwHighDateTime);                                     \
+        DEBUG_INFO((label" - %s", pst_fileTimeToAscii(targ, time_buffer))); \
+    }                                                                       \
 }
 
 #define LIST_COPY_EMAIL_TIME(label, targ) {                     \