From bcc44873d949bd817fa19fad368604cf73ccee78 Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Thu, 30 Aug 2012 23:10:07 +0300 Subject: pktdumper: Use av_strlcpy instead of strncpy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This takes care of null-terminating the buffer if it is too small, which wasn't handled properly before. Signed-off-by: Martin Storsjö --- tools/pktdumper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/pktdumper.c b/tools/pktdumper.c index fffeeeb70a..f21a8e01e7 100644 --- a/tools/pktdumper.c +++ b/tools/pktdumper.c @@ -31,6 +31,7 @@ #include #endif +#include "libavutil/avstring.h" #include "libavutil/time.h" #include "libavformat/avformat.h" @@ -70,9 +71,9 @@ int main(int argc, char **argv) return usage(1); if (argc > 2) maxpkts = atoi(argv[2]); - strncpy(fntemplate, argv[1], sizeof(fntemplate) - 1); + av_strlcpy(fntemplate, argv[1], sizeof(fntemplate)); if (strrchr(argv[1], '/')) - strncpy(fntemplate, strrchr(argv[1], '/') + 1, sizeof(fntemplate) - 1); + av_strlcpy(fntemplate, strrchr(argv[1], '/') + 1, sizeof(fntemplate)); if (strrchr(fntemplate, '.')) *strrchr(fntemplate, '.') = '\0'; if (strchr(fntemplate, '%')) { -- cgit v1.2.3