[MPlayer-cvslog] r34895 - trunk/stream/stream_pvr.c
reimar
subversion at mplayerhq.hu
Sun May 13 20:58:32 CEST 2012
Author: reimar
Date: Sun May 13 20:58:32 2012
New Revision: 34895
Log:
stream_pvr: Use sizeof() to get destination buffer size.
The code in lines 382/384 used the wrong constant.
Fixes bug #2066.
Modified:
trunk/stream/stream_pvr.c
Modified: trunk/stream/stream_pvr.c
==============================================================================
--- trunk/stream/stream_pvr.c Tue May 8 15:56:23 2012 (r34894)
+++ trunk/stream/stream_pvr.c Sun May 13 20:58:32 2012 (r34895)
@@ -89,6 +89,9 @@ char *pvr_param_bitrate_mode = NULL;
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 @@ copycreate_stationlist (stationlist_t *s
/* 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 @@ set_station (struct pvr_t *pvr, const ch
}
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 @@ set_station (struct pvr_t *pvr, const ch
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 @@ parse_setup_stationlist (struct pvr_t *p
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] = ' ';
More information about the MPlayer-cvslog
mailing list