Mercurial > mplayer.hg
changeset 34807:0fa420bbf59a
stream_pvr: Use sizeof() to get destination buffer size.
The code in lines 382/384 used the wrong constant.
Fixes bug #2066.
author | reimar |
---|---|
date | Sun, 13 May 2012 18:58:32 +0000 |
parents | 5048d421691d |
children | 275c92f137ac |
files | stream/stream_pvr.c |
diffstat | 1 files changed, 13 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/stream/stream_pvr.c Tue May 08 13:56:23 2012 +0000 +++ b/stream/stream_pvr.c Sun May 13 18:58:32 2012 +0000 @@ -89,6 +89,9 @@ int pvr_param_bitrate_peak = 0; char *pvr_param_stream_type = NULL; +#define BUFSTRCPY(d, s) av_strlcpy(d, s, sizeof(d)) +#define BUFPRINTF(d, ...) snprintf(d, sizeof(d), __VA_ARGS__) + typedef struct station_elem_s { char name[8]; int freq; @@ -227,13 +230,12 @@ /* transport the channel list data to our extented struct */ stationlist->total = num; - av_strlcpy (stationlist->name, chanlists[chantab].name, PVR_STATION_NAME_SIZE); + BUFSTRCPY(stationlist->name, chanlists[chantab].name); for (i = 0; i < chanlists[chantab].count; i++) { stationlist->list[i].station[0]= '\0'; /* no station name yet */ - av_strlcpy (stationlist->list[i].name, - chanlists[chantab].list[i].name, PVR_STATION_NAME_SIZE); + BUFSTRCPY(stationlist->list[i].name, chanlists[chantab].list[i].name); stationlist->list[i].freq = chanlists[chantab].list[i].freq; stationlist->list[i].enabled = 1; /* default enabled */ stationlist->enabled++; @@ -319,14 +321,11 @@ } if (station) - av_strlcpy (pvr->stationlist.list[i].station, - station, PVR_STATION_NAME_SIZE); + BUFSTRCPY(pvr->stationlist.list[i].station, station); else if (channel) - av_strlcpy (pvr->stationlist.list[i].station, - channel, PVR_STATION_NAME_SIZE); + BUFSTRCPY(pvr->stationlist.list[i].station, channel); else - snprintf (pvr->stationlist.list[i].station, - PVR_STATION_NAME_SIZE, "F %d", freq); + BUFPRINTF(pvr->stationlist.list[i].station, "F %d", freq); mp_msg (MSGT_OPEN, MSGL_DBG2, "%s Set user station channel: %8s - freq: %8d - station: %s\n", @@ -376,13 +375,11 @@ pvr->stationlist.enabled++; if (station) - av_strlcpy (pvr->stationlist.list[i].station, - station, PVR_STATION_NAME_SIZE); + BUFSTRCPY(pvr->stationlist.list[i].station, station); if (channel) - av_strlcpy (pvr->stationlist.list[i].name, channel, PVR_STATION_NAME_SIZE); + BUFSTRCPY(pvr->stationlist.list[i].name, channel); else - snprintf (pvr->stationlist.list[i].name, - PVR_STATION_NAME_SIZE, "F %d", freq); + BUFPRINTF(pvr->stationlist.list[i].name, "F %d", freq); pvr->stationlist.list[i].freq = freq; @@ -471,10 +468,10 @@ if (!sep) continue; /* Wrong syntax, but mplayer should not crash */ - av_strlcpy (station, sep + 1, PVR_STATION_NAME_SIZE); + BUFSTRCPY(station, sep + 1); sep[0] = '\0'; - av_strlcpy (channel, tmp, PVR_STATION_NAME_SIZE); + BUFSTRCPY(channel, tmp); while ((sep = strchr (station, '_'))) sep[0] = ' ';