X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Ftime-dst.c;h=2797d1a7968a2b548fa73e3118bbadbeed0f01fe;hb=7432b24b8357d913943580b442ffe7040e610f9e;hp=3950a882bf46b7600f77730452252902723653f5;hpb=11f22867f9cdbfc6656905861090cded91a41bd7;p=elogind.git
diff --git a/src/shared/time-dst.c b/src/shared/time-dst.c
index 3950a882b..2797d1a79 100644
--- a/src/shared/time-dst.c
+++ b/src/shared/time-dst.c
@@ -21,18 +21,12 @@
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see .
***/
-#include
#include
#include
#include
-#include
#include
#include
#include
-#include
-#include
-#include
-#include
#include
#include
#include
@@ -183,7 +177,8 @@ read_again:
return -EINVAL;
}
- transitions = (time_t *)calloc(total_size + tzspec_len, 1);
+ /* leave space for additional zone_names zero terminator */
+ transitions = malloc0(total_size + tzspec_len + 1);
if (transitions == NULL)
return -EINVAL;
@@ -207,8 +202,8 @@ read_again:
if (type_idxs[i] >= num_types)
return -EINVAL;
- if ((BYTE_ORDER != BIG_ENDIAN && (sizeof(time_t) == 4 || trans_width == 4)) ||
- (BYTE_ORDER == BIG_ENDIAN && sizeof(time_t) == 8 && trans_width == 4)) {
+ if (__BYTE_ORDER == __BIG_ENDIAN ? sizeof(time_t) == 8 && trans_width == 4
+ : sizeof(time_t) == 4 || trans_width == 4) {
/* Decode the transition times, stored as 4-byte integers in
network (big-endian) byte order. We work from the end of
the array so as not to clobber the next element to be
@@ -216,7 +211,7 @@ read_again:
i = num_transitions;
while (i-- > 0)
transitions[i] = decode((char *)transitions + i * 4);
- } else if (BYTE_ORDER != BIG_ENDIAN && sizeof(time_t) == 8) {
+ } else if (__BYTE_ORDER != __BIG_ENDIAN && sizeof(time_t) == 8) {
/* Decode the transition times, stored as 8-byte integers in
network (big-endian) byte order. */
for (i = 0; i < num_transitions; ++i)
@@ -244,6 +239,8 @@ read_again:
if (fread(zone_names, 1, chars, f) != chars)
return -EINVAL;
+ zone_names[chars] = '\0';
+
for (i = 0; i < num_isstd; ++i) {
int c = getc(f);
if (c == EOF)