Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / stable / src / modules / mptr_mplayer / mptr_mplayer.cpp
index d1c6fb4..9e3d547 100644 (file)
@@ -1,18 +1,22 @@
-/*! ========================================================================
-** Sinfg
-** ppm Target Module
-** $Id: mptr_mplayer.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
+/* === S Y N F I G ========================================================= */
+/*!    \file mptr_mplayer.cpp
+**     \brief ppm Target Module
 **
-** Copyright (c) 2002 Robert B. Quattlebaum Jr.
+**     $Id$
 **
-** This software and associated documentation
-** are CONFIDENTIAL and PROPRIETARY property of
-** the above-mentioned copyright holder.
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
 **
-** You may not copy, print, publish, or in any
-** other way distribute this software without
-** a prior written agreement with
-** the copyright holder.
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
+**
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
+**     \endlegal
 **
 ** === N O T E S ===========================================================
 **
@@ -27,7 +31,7 @@
 #      include <config.h>
 #endif
 
-#include <sinfg/sinfg.h>
+#include <synfig/synfig.h>
 #include <ETL/stringf>
 #include "mptr_mplayer.h"
 #include <stdio.h>
@@ -39,7 +43,7 @@
 
 /* === M A C R O S ========================================================= */
 
-using namespace sinfg;
+using namespace synfig;
 using namespace std;
 using namespace etl;
 
@@ -66,11 +70,14 @@ mplayer_mptr::~mplayer_mptr()
 }
 
 bool
-mplayer_mptr::GetFrame(Time time, sinfg::Surface &surface, sinfg::ProgressCallback *)
+mplayer_mptr::GetFrame(Time time, synfig::Surface &surface, synfig::ProgressCallback *)
 {
+
+#error This code has vulnerabilites: arbitrary shell command execution and tmpfile issues
+
        int ret;
        ret=system(
-               strprintf("/usr/local/bin/mencoder \"%s\" -ovc rawrgb -ss %f -endpos 0 -nosound -o /tmp/tmp.sinfg.rgbdata | grep \"VIDEO\" > /tmp/tmp.sinfg.size",
+               strprintf("/usr/local/bin/mencoder \"%s\" -ovc rawrgb -ss %f -endpos 0 -nosound -o /tmp/tmp.synfig.rgbdata | grep \"VIDEO\" > /tmp/tmp.synfig.size",
                        filename.c_str(),
                        time
                ).c_str()
@@ -82,24 +89,24 @@ mplayer_mptr::GetFrame(Time time, sinfg::Surface &surface, sinfg::ProgressCallba
                return false;
        }
 */
-       FILE *sizefile=fopen("/tmp/tmp.sinfg.size","rt");
-       FILE *rgbfile=fopen("/tmp/tmp.sinfg.rgbdata","rb");
+       FILE *sizefile=fopen("/tmp/tmp.synfig.size","rt");
+       FILE *rgbfile=fopen("/tmp/tmp.synfig.rgbdata","rb");
        if(!rgbfile)
        {
-               cerr<<"unable to open /tmp/tmp.sinfg.rgbdata"<<endl;
+               cerr<<"unable to open /tmp/tmp.synfig.rgbdata"<<endl;
                return false;
        }
        if(!sizefile)
        {
-               cerr<<"unable to open /tmp/tmp.sinfg.size"<<endl;
+               cerr<<"unable to open /tmp/tmp.synfig.size"<<endl;
                return false;
        }
-       
+
        int w=4,h=4,x,y;
        char bleh[500];
-       
+
        fscanf(sizefile,"%s %s %dx%d",bleh,bleh,&w,&h);
-       
+
        cerr<<strprintf("w:%d, h:%d, time:%f",w,h,time)<<endl;
        fseek(rgbfile,2047+3*8,SEEK_CUR);
        surface.set_wh(w,h);
@@ -110,7 +117,7 @@ mplayer_mptr::GetFrame(Time time, sinfg::Surface &surface, sinfg::ProgressCallba
                                b=(unsigned char)fgetc(rgbfile),
                                g=(unsigned char)fgetc(rgbfile),
                                r=(unsigned char)fgetc(rgbfile);
-                               
+
                        surface[h-y-1][x]=Color(
                                (float)r/255.0,
                                (float)g/255.0,
@@ -118,9 +125,9 @@ mplayer_mptr::GetFrame(Time time, sinfg::Surface &surface, sinfg::ProgressCallba
                                1.0
                        );
                }
-       
+
        fclose(rgbfile);
        fclose(sizefile);
-       
+
        return true;
 }