check that the input file exists. make sure that the input file doesn't equal the...
authortsauerbeck <tsauerbeck>
Sat, 16 Oct 2004 11:34:09 +0000 (11:34 +0000)
committertsauerbeck <tsauerbeck@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 16 Oct 2004 11:34:09 +0000 (11:34 +0000)
SVN revision: 11891

legacy/edje/src/bin/edje_cc.c

index 10e6ce8..cf733f6 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ * vim:ts=8:sw=3:sts=3:noexpandtab
+ */
+
 #include "edje_cc.h"
 
 static void main_help(void);
@@ -45,6 +49,8 @@ int
 main(int argc, char **argv)
 {
    int i;
+   struct stat st;
+   char rpath[PATH_MAX], rpath2[PATH_MAX];
 
    setlocale(LC_NUMERIC, "C");
    
@@ -128,6 +134,15 @@ main(int argc, char **argv)
        main_help();
        exit(-1);
      }
+
+   /* check whether file_in exists */
+   if (!realpath(file_in, rpath) || stat(rpath, &st) || !S_ISREG(st.st_mode))
+     {
+       fprintf(stderr, "%s: Error: file not found: %s.\n", progname, file_in);
+       main_help();
+       exit(-1);
+     }
+
    if (!file_out)
       {
          char *suffix;
@@ -149,6 +164,13 @@ main(int argc, char **argv)
        exit(-1);
      }
 
+   if (realpath(file_out, rpath2) && !strcmp (rpath, rpath2))
+     {
+       fprintf(stderr, "%s: Error: input file equals output file.\n", progname);
+       main_help();
+       exit(-1);
+     }
+
    edje_init();
 
    edje_file = mem_alloc(SZ(Edje_File));