chiark / gitweb /
tree-wide: there is no ENOTSUP on linux
[elogind.git] / src / shared / time-dst.c
index 6195b110176a3f05001a5d0c5d2c02a1795eddac..2797d1a7968a2b548fa73e3118bbadbeed0f01fe 100644 (file)
   You should have received a copy of the GNU Lesser General Public License
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
-#include <ctype.h>
 #include <errno.h>
 #include <stddef.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 #include <time.h>
 #include <endian.h>
-#include <byteswap.h>
-#include <assert.h>
-#include <limits.h>
-#include <unistd.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <sys/stat.h>
@@ -183,7 +177,8 @@ read_again:
                         return -EINVAL;
         }
 
-        transitions = malloc0(total_size + tzspec_len);
+        /* leave space for additional zone_names zero terminator */
+        transitions = malloc0(total_size + tzspec_len + 1);
         if (transitions == NULL)
                 return -EINVAL;
 
@@ -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)