Fix possible out of bound write in winpr_read_unix_timezone_identifier_from_file
If the timezone can not be read from the file (read 0 bytes) then memory
at a random position (buffer[-1] = '\0') will be set to zero.
@@ -64,6 +64,7 @@ static char* winpr_read_unix_timezone_identifier_from_file(FILE* fp)
do
{
rc = fread(tzid + read, 1, length - read - 1, fp);
+ if (rc > 0)
read += rc;
if (read < (length - 1))
@@ -87,8 +88,11 @@ static char* winpr_read_unix_timezone_identifier_from_file(FILE* fp)
}
tzid[read] = '\0';
+ if (read > 0)
+ {
if (tzid[read - 1] == '\n')
tzid[read - 1] = '\0';
+ }
return tzid;
}
