Hi,

The screenshot module makes use of the mkstemps fuction which is
non-standard. (NetBSD doesn't have it, for example.) Also, the way it is
used, it leaks a file descriptor, and the return value isn't checked
correctly. Because the file is unlinked shortly after creating, I
didn't think it necessary to use a mkstemp like function and patched it
locally with the attached diff. Any comments?

kind regards
dieter
--- src/modules/shot/e_mod_main.c.orig  2012-12-02 11:14:34.000000000 +0000
+++ src/modules/shot/e_mod_main.c
@@ -431,11 +431,19 @@ _win_share_cb(void *data __UNUSED__, voi
    Evas_Object *o, *ol;
    Evas_Coord mw, mh;
    char buf[PATH_MAX];
+   int i = 0, fd;
    FILE *f;
    
-   if (quality == 100) snprintf(buf, sizeof(buf), "/tmp/e-shot-XXXXXX.png");
-   else snprintf(buf, sizeof(buf), "/tmp/e-shot-XXXXXX.jpg");
-   if (!mkstemps(buf, 4))
+   do
+     {
+        snprintf(buf, sizeof(buf), "/tmp/e-shot-%03d.%s", i++,
+                 (quality == 100 ? "png" : "jpg"));
+        if ((fd = open(buf, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR)) >= 0)
+          break;
+     }
+   while (i < 1000);
+
+   if (fd < 0)
      {
         e_util_dialog_show(_("Error - Can't create file"),
                            _("Cannot create temporary file '%s': %s"),
@@ -447,6 +460,7 @@ _win_share_cb(void *data __UNUSED__, voi
           }
         return;
      }
+   close(fd);
    _save_to(buf);
    if (win)
      {
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to