Commit a94e59ca authored by Max Kellermann's avatar Max Kellermann

stored_playlist: fix integer overflow in length estimation

With a large maximum playlist length, the integer multiplication "playlist_max_length * MPD_PATH_MAX" may overflow. Change that to a division. This was not a dangerous bug, since it was only used for a quick estimate.
parent 7f98ba24
...@@ -338,7 +338,7 @@ spl_append_song(const char *utf8path, struct song *song) ...@@ -338,7 +338,7 @@ spl_append_song(const char *utf8path, struct song *song)
return PLAYLIST_RESULT_ERRNO; return PLAYLIST_RESULT_ERRNO;
} }
if (st.st_size >= ((MPD_PATH_MAX+1) * (off_t)playlist_max_length)) { if (st.st_size / (MPD_PATH_MAX + 1) >= (off_t)playlist_max_length) {
while (fclose(file) != 0 && errno == EINTR); while (fclose(file) != 0 && errno == EINTR);
return PLAYLIST_RESULT_TOO_LARGE; return PLAYLIST_RESULT_TOO_LARGE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment