| ... | ... |
@@ -3695,8 +3695,7 @@ static int opt_streamid(const char *opt, const char *arg) |
| 3695 | 3695 |
char *p; |
| 3696 | 3696 |
char idx_str[16]; |
| 3697 | 3697 |
|
| 3698 |
- strncpy(idx_str, arg, sizeof(idx_str)); |
|
| 3699 |
- idx_str[sizeof(idx_str)-1] = '\0'; |
|
| 3698 |
+ av_strlcpy(idx_str, arg, sizeof(idx_str)); |
|
| 3700 | 3699 |
p = strchr(idx_str, ':'); |
| 3701 | 3700 |
if (!p) {
|
| 3702 | 3701 |
fprintf(stderr, |
| ... | ... |
@@ -33,6 +33,7 @@ |
| 33 | 33 |
|
| 34 | 34 |
#include "libavutil/audioconvert.h" |
| 35 | 35 |
#include "libavutil/avassert.h" |
| 36 |
+#include "libavutil/avstring.h" |
|
| 36 | 37 |
#include "libavutil/crc.h" |
| 37 | 38 |
#include "libavutil/opt.h" |
| 38 | 39 |
#include "avcodec.h" |
| ... | ... |
@@ -1578,10 +1579,10 @@ static void dprint_options(AVCodecContext *avctx) |
| 1578 | 1578 |
char strbuf[32]; |
| 1579 | 1579 |
|
| 1580 | 1580 |
switch (s->bitstream_id) {
|
| 1581 |
- case 6: strncpy(strbuf, "AC-3 (alt syntax)", 32); break; |
|
| 1582 |
- case 8: strncpy(strbuf, "AC-3 (standard)", 32); break; |
|
| 1583 |
- case 9: strncpy(strbuf, "AC-3 (dnet half-rate)", 32); break; |
|
| 1584 |
- case 10: strncpy(strbuf, "AC-3 (dnet quater-rate", 32); break; |
|
| 1581 |
+ case 6: av_strlcpy(strbuf, "AC-3 (alt syntax)", 32); break; |
|
| 1582 |
+ case 8: av_strlcpy(strbuf, "AC-3 (standard)", 32); break; |
|
| 1583 |
+ case 9: av_strlcpy(strbuf, "AC-3 (dnet half-rate)", 32); break; |
|
| 1584 |
+ case 10: av_strlcpy(strbuf, "AC-3 (dnet quater-rate", 32); break; |
|
| 1585 | 1585 |
default: snprintf(strbuf, 32, "ERROR"); |
| 1586 | 1586 |
} |
| 1587 | 1587 |
av_dlog(avctx, "bitstream_id: %s (%d)\n", strbuf, s->bitstream_id); |
| ... | ... |
@@ -1608,9 +1609,9 @@ static void dprint_options(AVCodecContext *avctx) |
| 1608 | 1608 |
if (opt->audio_production_info) {
|
| 1609 | 1609 |
av_dlog(avctx, "mixing_level: %ddB\n", opt->mixing_level); |
| 1610 | 1610 |
switch (opt->room_type) {
|
| 1611 |
- case 0: strncpy(strbuf, "notindicated", 32); break; |
|
| 1612 |
- case 1: strncpy(strbuf, "large", 32); break; |
|
| 1613 |
- case 2: strncpy(strbuf, "small", 32); break; |
|
| 1611 |
+ case 0: av_strlcpy(strbuf, "notindicated", 32); break; |
|
| 1612 |
+ case 1: av_strlcpy(strbuf, "large", 32); break; |
|
| 1613 |
+ case 2: av_strlcpy(strbuf, "small", 32); break; |
|
| 1614 | 1614 |
default: snprintf(strbuf, 32, "ERROR (%d)", opt->room_type); |
| 1615 | 1615 |
} |
| 1616 | 1616 |
av_dlog(avctx, "room_type: %s\n", strbuf); |
| ... | ... |
@@ -1622,9 +1623,9 @@ static void dprint_options(AVCodecContext *avctx) |
| 1622 | 1622 |
av_dlog(avctx, "dialnorm: %ddB\n", opt->dialogue_level); |
| 1623 | 1623 |
if (s->channel_mode == AC3_CHMODE_STEREO) {
|
| 1624 | 1624 |
switch (opt->dolby_surround_mode) {
|
| 1625 |
- case 0: strncpy(strbuf, "notindicated", 32); break; |
|
| 1626 |
- case 1: strncpy(strbuf, "on", 32); break; |
|
| 1627 |
- case 2: strncpy(strbuf, "off", 32); break; |
|
| 1625 |
+ case 0: av_strlcpy(strbuf, "notindicated", 32); break; |
|
| 1626 |
+ case 1: av_strlcpy(strbuf, "on", 32); break; |
|
| 1627 |
+ case 2: av_strlcpy(strbuf, "off", 32); break; |
|
| 1628 | 1628 |
default: snprintf(strbuf, 32, "ERROR (%d)", opt->dolby_surround_mode); |
| 1629 | 1629 |
} |
| 1630 | 1630 |
av_dlog(avctx, "dsur_mode: %s\n", strbuf); |
| ... | ... |
@@ -1636,9 +1637,9 @@ static void dprint_options(AVCodecContext *avctx) |
| 1636 | 1636 |
if (s->bitstream_id == 6) {
|
| 1637 | 1637 |
if (opt->extended_bsi_1) {
|
| 1638 | 1638 |
switch (opt->preferred_stereo_downmix) {
|
| 1639 |
- case 0: strncpy(strbuf, "notindicated", 32); break; |
|
| 1640 |
- case 1: strncpy(strbuf, "ltrt", 32); break; |
|
| 1641 |
- case 2: strncpy(strbuf, "loro", 32); break; |
|
| 1639 |
+ case 0: av_strlcpy(strbuf, "notindicated", 32); break; |
|
| 1640 |
+ case 1: av_strlcpy(strbuf, "ltrt", 32); break; |
|
| 1641 |
+ case 2: av_strlcpy(strbuf, "loro", 32); break; |
|
| 1642 | 1642 |
default: snprintf(strbuf, 32, "ERROR (%d)", opt->preferred_stereo_downmix); |
| 1643 | 1643 |
} |
| 1644 | 1644 |
av_dlog(avctx, "dmix_mode: %s\n", strbuf); |
| ... | ... |
@@ -1655,23 +1656,23 @@ static void dprint_options(AVCodecContext *avctx) |
| 1655 | 1655 |
} |
| 1656 | 1656 |
if (opt->extended_bsi_2) {
|
| 1657 | 1657 |
switch (opt->dolby_surround_ex_mode) {
|
| 1658 |
- case 0: strncpy(strbuf, "notindicated", 32); break; |
|
| 1659 |
- case 1: strncpy(strbuf, "on", 32); break; |
|
| 1660 |
- case 2: strncpy(strbuf, "off", 32); break; |
|
| 1658 |
+ case 0: av_strlcpy(strbuf, "notindicated", 32); break; |
|
| 1659 |
+ case 1: av_strlcpy(strbuf, "on", 32); break; |
|
| 1660 |
+ case 2: av_strlcpy(strbuf, "off", 32); break; |
|
| 1661 | 1661 |
default: snprintf(strbuf, 32, "ERROR (%d)", opt->dolby_surround_ex_mode); |
| 1662 | 1662 |
} |
| 1663 | 1663 |
av_dlog(avctx, "dsurex_mode: %s\n", strbuf); |
| 1664 | 1664 |
switch (opt->dolby_headphone_mode) {
|
| 1665 |
- case 0: strncpy(strbuf, "notindicated", 32); break; |
|
| 1666 |
- case 1: strncpy(strbuf, "on", 32); break; |
|
| 1667 |
- case 2: strncpy(strbuf, "off", 32); break; |
|
| 1665 |
+ case 0: av_strlcpy(strbuf, "notindicated", 32); break; |
|
| 1666 |
+ case 1: av_strlcpy(strbuf, "on", 32); break; |
|
| 1667 |
+ case 2: av_strlcpy(strbuf, "off", 32); break; |
|
| 1668 | 1668 |
default: snprintf(strbuf, 32, "ERROR (%d)", opt->dolby_headphone_mode); |
| 1669 | 1669 |
} |
| 1670 | 1670 |
av_dlog(avctx, "dheadphone_mode: %s\n", strbuf); |
| 1671 | 1671 |
|
| 1672 | 1672 |
switch (opt->ad_converter_type) {
|
| 1673 |
- case 0: strncpy(strbuf, "standard", 32); break; |
|
| 1674 |
- case 1: strncpy(strbuf, "hdcd", 32); break; |
|
| 1673 |
+ case 0: av_strlcpy(strbuf, "standard", 32); break; |
|
| 1674 |
+ case 1: av_strlcpy(strbuf, "hdcd", 32); break; |
|
| 1675 | 1675 |
default: snprintf(strbuf, 32, "ERROR (%d)", opt->ad_converter_type); |
| 1676 | 1676 |
} |
| 1677 | 1677 |
av_dlog(avctx, "ad_conv_type: %s\n", strbuf); |
| ... | ... |
@@ -21,6 +21,7 @@ |
| 21 | 21 |
|
| 22 | 22 |
#include "avcodec.h" |
| 23 | 23 |
#include "ass.h" |
| 24 |
+#include "libavutil/avstring.h" |
|
| 24 | 25 |
|
| 25 | 26 |
/** |
| 26 | 27 |
* Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS. |
| ... | ... |
@@ -117,8 +118,7 @@ int ff_ass_add_rect(AVSubtitle *sub, const char *dialog, |
| 117 | 117 |
rects[sub->num_rects]->type = SUBTITLE_ASS; |
| 118 | 118 |
rects[sub->num_rects]->ass = av_malloc(len + dlen + 1); |
| 119 | 119 |
strcpy (rects[sub->num_rects]->ass , header); |
| 120 |
- strncpy(rects[sub->num_rects]->ass + len, dialog, dlen); |
|
| 121 |
- rects[sub->num_rects]->ass[len+dlen] = 0; |
|
| 120 |
+ av_strlcpy(rects[sub->num_rects]->ass + len, dialog, dlen + 1); |
|
| 122 | 121 |
sub->num_rects++; |
| 123 | 122 |
return dlen; |
| 124 | 123 |
} |
| ... | ... |
@@ -827,7 +827,7 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track) |
| 827 | 827 |
memset(compressor_name,0,32); |
| 828 | 828 |
/* FIXME not sure, ISO 14496-1 draft where it shall be set to 0 */ |
| 829 | 829 |
if (track->mode == MODE_MOV && track->enc->codec && track->enc->codec->name) |
| 830 |
- strncpy(compressor_name,track->enc->codec->name,31); |
|
| 830 |
+ av_strlcpy(compressor_name,track->enc->codec->name,32); |
|
| 831 | 831 |
avio_w8(pb, strlen(compressor_name)); |
| 832 | 832 |
avio_write(pb, compressor_name, 31); |
| 833 | 833 |
|
| ... | ... |
@@ -24,6 +24,7 @@ |
| 24 | 24 |
#include "id3v1.h" |
| 25 | 25 |
#include "id3v2.h" |
| 26 | 26 |
#include "rawenc.h" |
| 27 |
+#include "libavutil/avstring.h" |
|
| 27 | 28 |
#include "libavutil/intreadwrite.h" |
| 28 | 29 |
#include "libavutil/opt.h" |
| 29 | 30 |
|
| ... | ... |
@@ -32,7 +33,7 @@ static int id3v1_set_string(AVFormatContext *s, const char *key, |
| 32 | 32 |
{
|
| 33 | 33 |
AVMetadataTag *tag; |
| 34 | 34 |
if ((tag = av_metadata_get(s->metadata, key, NULL, 0))) |
| 35 |
- strncpy(buf, tag->value, buf_size); |
|
| 35 |
+ av_strlcpy(buf, tag->value, buf_size); |
|
| 36 | 36 |
return !!tag; |
| 37 | 37 |
} |
| 38 | 38 |
|
| ... | ... |
@@ -26,6 +26,7 @@ |
| 26 | 26 |
|
| 27 | 27 |
#include <unistd.h> |
| 28 | 28 |
#include <stdlib.h> |
| 29 |
+#include "avstring.h" |
|
| 29 | 30 |
#include "avutil.h" |
| 30 | 31 |
#include "log.h" |
| 31 | 32 |
|
| ... | ... |
@@ -120,7 +121,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) |
| 120 | 120 |
count=0; |
| 121 | 121 |
} |
| 122 | 122 |
colored_fputs(av_clip(level>>3, 0, 6), line); |
| 123 |
- strncpy(prev, line, sizeof line); |
|
| 123 |
+ av_strlcpy(prev, line, sizeof line); |
|
| 124 | 124 |
} |
| 125 | 125 |
|
| 126 | 126 |
static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback; |
| ... | ... |
@@ -86,6 +86,7 @@ try to unroll inner for(x=0 ... loop to avoid these damn if(x ... checks |
| 86 | 86 |
//#define DEBUG_BRIGHTNESS |
| 87 | 87 |
#include "postprocess.h" |
| 88 | 88 |
#include "postprocess_internal.h" |
| 89 |
+#include "libavutil/avstring.h" |
|
| 89 | 90 |
|
| 90 | 91 |
unsigned postproc_version(void) |
| 91 | 92 |
{
|
| ... | ... |
@@ -762,7 +763,7 @@ pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality) |
| 762 | 762 |
ppMode->maxClippedThreshold= 0.01; |
| 763 | 763 |
ppMode->error=0; |
| 764 | 764 |
|
| 765 |
- strncpy(temp, name, GET_MODE_BUFFER_SIZE); |
|
| 765 |
+ av_strlcpy(temp, name, GET_MODE_BUFFER_SIZE); |
|
| 766 | 766 |
|
| 767 | 767 |
av_log(NULL, AV_LOG_DEBUG, "pp: %s\n", name); |
| 768 | 768 |
|