diff options
author | Alex Converse <aconverse@google.com> | 2011-05-03 11:19:31 -0700 |
---|---|---|
committer | Alex Converse <alex.converse@gmail.com> | 2011-05-03 21:20:13 -0700 |
commit | 1a5e4fd8c5b99478b4e08a69261930bb12aa948b (patch) | |
tree | 305d316548f3f399606e2659ee0fec7e2a13ae59 /libavcodec | |
parent | aab6374bbe2b6ce4ca82141be6a5b7b8875bf051 (diff) | |
download | ffmpeg-1a5e4fd8c5b99478b4e08a69261930bb12aa948b.tar.gz |
Replace strncpy() with av_strlcpy().
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/ac3enc.c | 43 | ||||
-rw-r--r-- | libavcodec/ass.c | 4 |
2 files changed, 24 insertions, 23 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index bf106eb22a..a35ff29d1a 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -33,6 +33,7 @@ #include "libavutil/audioconvert.h" #include "libavutil/avassert.h" +#include "libavutil/avstring.h" #include "libavutil/crc.h" #include "libavutil/opt.h" #include "avcodec.h" @@ -1578,10 +1579,10 @@ static void dprint_options(AVCodecContext *avctx) char strbuf[32]; switch (s->bitstream_id) { - case 6: strncpy(strbuf, "AC-3 (alt syntax)", 32); break; - case 8: strncpy(strbuf, "AC-3 (standard)", 32); break; - case 9: strncpy(strbuf, "AC-3 (dnet half-rate)", 32); break; - case 10: strncpy(strbuf, "AC-3 (dnet quater-rate", 32); break; + case 6: av_strlcpy(strbuf, "AC-3 (alt syntax)", 32); break; + case 8: av_strlcpy(strbuf, "AC-3 (standard)", 32); break; + case 9: av_strlcpy(strbuf, "AC-3 (dnet half-rate)", 32); break; + case 10: av_strlcpy(strbuf, "AC-3 (dnet quater-rate", 32); break; default: snprintf(strbuf, 32, "ERROR"); } av_dlog(avctx, "bitstream_id: %s (%d)\n", strbuf, s->bitstream_id); @@ -1608,9 +1609,9 @@ static void dprint_options(AVCodecContext *avctx) if (opt->audio_production_info) { av_dlog(avctx, "mixing_level: %ddB\n", opt->mixing_level); switch (opt->room_type) { - case 0: strncpy(strbuf, "notindicated", 32); break; - case 1: strncpy(strbuf, "large", 32); break; - case 2: strncpy(strbuf, "small", 32); break; + case 0: av_strlcpy(strbuf, "notindicated", 32); break; + case 1: av_strlcpy(strbuf, "large", 32); break; + case 2: av_strlcpy(strbuf, "small", 32); break; default: snprintf(strbuf, 32, "ERROR (%d)", opt->room_type); } av_dlog(avctx, "room_type: %s\n", strbuf); @@ -1622,9 +1623,9 @@ static void dprint_options(AVCodecContext *avctx) av_dlog(avctx, "dialnorm: %ddB\n", opt->dialogue_level); if (s->channel_mode == AC3_CHMODE_STEREO) { switch (opt->dolby_surround_mode) { - case 0: strncpy(strbuf, "notindicated", 32); break; - case 1: strncpy(strbuf, "on", 32); break; - case 2: strncpy(strbuf, "off", 32); break; + case 0: av_strlcpy(strbuf, "notindicated", 32); break; + case 1: av_strlcpy(strbuf, "on", 32); break; + case 2: av_strlcpy(strbuf, "off", 32); break; default: snprintf(strbuf, 32, "ERROR (%d)", opt->dolby_surround_mode); } av_dlog(avctx, "dsur_mode: %s\n", strbuf); @@ -1636,9 +1637,9 @@ static void dprint_options(AVCodecContext *avctx) if (s->bitstream_id == 6) { if (opt->extended_bsi_1) { switch (opt->preferred_stereo_downmix) { - case 0: strncpy(strbuf, "notindicated", 32); break; - case 1: strncpy(strbuf, "ltrt", 32); break; - case 2: strncpy(strbuf, "loro", 32); break; + case 0: av_strlcpy(strbuf, "notindicated", 32); break; + case 1: av_strlcpy(strbuf, "ltrt", 32); break; + case 2: av_strlcpy(strbuf, "loro", 32); break; default: snprintf(strbuf, 32, "ERROR (%d)", opt->preferred_stereo_downmix); } av_dlog(avctx, "dmix_mode: %s\n", strbuf); @@ -1655,23 +1656,23 @@ static void dprint_options(AVCodecContext *avctx) } if (opt->extended_bsi_2) { switch (opt->dolby_surround_ex_mode) { - case 0: strncpy(strbuf, "notindicated", 32); break; - case 1: strncpy(strbuf, "on", 32); break; - case 2: strncpy(strbuf, "off", 32); break; + case 0: av_strlcpy(strbuf, "notindicated", 32); break; + case 1: av_strlcpy(strbuf, "on", 32); break; + case 2: av_strlcpy(strbuf, "off", 32); break; default: snprintf(strbuf, 32, "ERROR (%d)", opt->dolby_surround_ex_mode); } av_dlog(avctx, "dsurex_mode: %s\n", strbuf); switch (opt->dolby_headphone_mode) { - case 0: strncpy(strbuf, "notindicated", 32); break; - case 1: strncpy(strbuf, "on", 32); break; - case 2: strncpy(strbuf, "off", 32); break; + case 0: av_strlcpy(strbuf, "notindicated", 32); break; + case 1: av_strlcpy(strbuf, "on", 32); break; + case 2: av_strlcpy(strbuf, "off", 32); break; default: snprintf(strbuf, 32, "ERROR (%d)", opt->dolby_headphone_mode); } av_dlog(avctx, "dheadphone_mode: %s\n", strbuf); switch (opt->ad_converter_type) { - case 0: strncpy(strbuf, "standard", 32); break; - case 1: strncpy(strbuf, "hdcd", 32); break; + case 0: av_strlcpy(strbuf, "standard", 32); break; + case 1: av_strlcpy(strbuf, "hdcd", 32); break; default: snprintf(strbuf, 32, "ERROR (%d)", opt->ad_converter_type); } av_dlog(avctx, "ad_conv_type: %s\n", strbuf); diff --git a/libavcodec/ass.c b/libavcodec/ass.c index beb1ba1141..327a77bb45 100644 --- a/libavcodec/ass.c +++ b/libavcodec/ass.c @@ -21,6 +21,7 @@ #include "avcodec.h" #include "ass.h" +#include "libavutil/avstring.h" /** * Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS. @@ -117,8 +118,7 @@ int ff_ass_add_rect(AVSubtitle *sub, const char *dialog, rects[sub->num_rects]->type = SUBTITLE_ASS; rects[sub->num_rects]->ass = av_malloc(len + dlen + 1); strcpy (rects[sub->num_rects]->ass , header); - strncpy(rects[sub->num_rects]->ass + len, dialog, dlen); - rects[sub->num_rects]->ass[len+dlen] = 0; + av_strlcpy(rects[sub->num_rects]->ass + len, dialog, dlen + 1); sub->num_rects++; return dlen; } |