[FFmpeg-cvslog] pktdumper: Use av_strlcpy instead of strncpy

Martin Storsjö git at videolan.org
Fri Aug 31 13:39:11 CEST 2012


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Thu Aug 30 23:10:07 2012 +0300| [bcc44873d949bd817fa19fad368604cf73ccee78] | committer: Martin Storsjö

pktdumper: Use av_strlcpy instead of strncpy

This takes care of null-terminating the buffer if it is too small,
which wasn't handled properly before.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bcc44873d949bd817fa19fad368604cf73ccee78
---

 tools/pktdumper.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/pktdumper.c b/tools/pktdumper.c
index fffeeeb..f21a8e0 100644
--- a/tools/pktdumper.c
+++ b/tools/pktdumper.c
@@ -31,6 +31,7 @@
 #include <io.h>
 #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, '%')) {



More information about the ffmpeg-cvslog mailing list