Package: sweep Version: 0.9.0-2 Followup-For: Bug #259386 Hi,
I investigated this problem a bit. It seems that the problem is caused by the behaviour of tmpfile(). ('sweep' uses this function to create temporary files.) The bad news is that tmpfile() is apparently the best choice of all the temporary file creation functions (it not only generates the name, but opens the file as well; it returns a (FILE *) pointer and not a file descriptor; it automatically removes the file on close; and it is reentrant), so it is a pity that we have to replace it with something else. (It is the fault of the Glibc implementation, I think, because the standard does not specify which directory tmpfile() should use.) I attached a patch that fixes this problem (I wrote a replacement function that uses mkstemp(), and simulates the behaviour of tmpfile()). The patch is a bit clumsy (the replacement function is inserted to the beginning of the only source file that uses tmpfile(), and not to a separate source file), but works, and this way there's no need to touch the Makefiles. norbi -- System Information: Debian Release: testing/unstable APT prefers testing APT policy: (500, 'testing'), (500, 'stable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.16 Locale: LANG=C, LC_CTYPE=hu_HU (charmap=ISO-8859-2) Versions of packages sweep depends on: ii libasound2 1.0.12-1 ALSA library ii libatk1.0-0 1.12.2-1 The ATK accessibility toolkit ii libc6 2.3.6.ds1-4 GNU C Library: Shared libraries ii libcairo2 1.2.4-1 The Cairo 2D vector graphics libra ii libesd-alsa0 0.2.36-3 Enlightened Sound Daemon (ALSA) - ii libfontconfig1 2.4.1-2 generic font configuration library ii libglib2.0-0 2.12.3-2 The GLib library of C routines ii libgtk2.0-0 2.8.20-1 The GTK+ graphical user interface ii libmad0 0.15.1b-2.1 MPEG audio decoder library ii libogg0 1.1.3-2 Ogg Bitstream Library ii libpango1.0-0 1.14.4-2 Layout and rendering of internatio ii libsamplerate0 0.1.2-2 audio rate conversion library ii libsndfile1 1.0.16-1 Library for reading/writing audio ii libspeex1 1.1.12-2 The Speex Speech Codec ii libvorbis0a 1.1.2-1 The Vorbis General Audio Compressi ii libvorbisenc2 1.1.2-1 The Vorbis General Audio Compressi ii libvorbisfile3 1.1.2-1 The Vorbis General Audio Compressi ii libx11-6 2:1.0.0-9 X11 client-side library ii libxcursor1 1.1.7-4 X cursor management library ii libxext6 1:1.0.1-2 X11 miscellaneous extension librar ii libxi6 1:1.0.1-3 X11 Input extension library ii libxinerama1 1:1.0.1-4.1 X11 Xinerama extension library ii libxrandr2 2:1.1.0.2-4 X11 RandR extension library ii libxrender1 1:0.9.1-3 X Rendering Extension client libra Versions of packages sweep recommends: pn cmt <none> (no description available) pn fil-plugins <none> (no description available) pn ladspa-plugin <none> (no description available) pn mcp-plugins <none> (no description available) pn swh-plugins <none> (no description available) pn tap-plugins <none> (no description available) -- no debconf information
diff -Naur sweep-0.9.0/src/edit.c sweep-0.9.0-fixed/src/edit.c --- sweep-0.9.0/src/edit.c 2005-12-21 03:28:02.000000000 +0100 +++ sweep-0.9.0-fixed/src/edit.c 2006-10-08 10:33:14.000000000 +0200 @@ -24,6 +24,7 @@ #include <stdio.h> #include <string.h> +#include <stdlib.h> #include <unistd.h> #include <sys/mman.h> @@ -43,6 +44,48 @@ #include "edit.h" #include "format.h" +int +is_directory(const char *entity) +{ + struct stat stat_buf; + + if (stat(entity, &stat_buf)) + return 0; + + return S_ISDIR(stat_buf.st_mode); +} + +FILE * +create_tmpfile(void) +{ + char *tmpdir; + size_t template_len; + char *template; + const char *filename_template = "sweepXXXXXX"; + int fd; + + tmpdir = getenv("TMPDIR"); + if (!tmpdir || !is_directory(tmpdir)) { + tmpdir = "/tmp"; + } + + template_len = strlen(tmpdir) + strlen("/") + strlen(filename_template) + 1; + template = (char *) malloc(template_len); + if (!template) + return NULL; + snprintf(template, template_len, "%s/%s", tmpdir, filename_template); + + fd = mkstemp(template); + + unlink(template); + + free(template); + + if (fd < 0) + return NULL; + + return fdopen(fd, "w+"); +} sw_edit_buffer * ebuf = NULL; @@ -55,8 +98,8 @@ FILE * f; int fd; - if ((f = tmpfile ()) == NULL) { - perror ("tmpfile failed in sweep_large_alloc_data"); + if ((f = create_tmpfile ()) == NULL) { + perror ("create_tmpfile failed in sweep_large_alloc_data"); return NULL; }