X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Ftime-dst.c;h=1ce6f721b7c895a5260d5b01b4faa92905d6f501;hb=fa6ac76083b8ffc1309876459f54f9f0e2843731;hp=6195b110176a3f05001a5d0c5d2c02a1795eddac;hpb=4f4b92ba7ae9c56cb0f181d5f95d709e085b8bd5;p=elogind.git diff --git a/src/shared/time-dst.c b/src/shared/time-dst.c index 6195b1101..1ce6f721b 100644 --- a/src/shared/time-dst.c +++ b/src/shared/time-dst.c @@ -183,7 +183,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 +245,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)