LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File sox-14.4.0-ocloexec.patch of Package sox (Project multimedia:apps)

--- src/8svx.c.orig
+++ src/8svx.c
@@ -161,7 +161,7 @@ static int startread(sox_format_t * ft)
         chan1_pos = lsx_tell(ft);
 
         for (i = 1; i < channels; i++) {
-                if ((p->ch[i] = fopen(ft->filename, "rb")) == NULL)
+                if ((p->ch[i] = fopen(ft->filename, "rbe")) == NULL)
                 {
                         lsx_fail_errno(ft,errno,"Can't open channel file '%s'",
                                 ft->filename);
--- src/effects_i.c.orig
+++ src/effects_i.c
@@ -355,7 +355,7 @@ FILE * lsx_open_input_file(sox_effect_t
     effp->global_info->global_info->stdin_in_use_by = effp->handler.name;
     file = stdin;
   }
-  else if (!(file = fopen(filename, "r"))) {
+  else if (!(file = fopen(filename, "re"))) {
     lsx_fail("couldn't open file %s: %s", filename, strerror(errno));
     return NULL;
   }
--- src/formats.c.orig
+++ src/formats.c
@@ -373,7 +373,7 @@ static FILE * xfopen(char const * identi
     FILE * f = NULL;
 #ifdef HAVE_POPEN
 #ifndef POPEN_MODE
-#define POPEN_MODE "r"
+#define POPEN_MODE "re"
 #endif
     f = popen(identifier + 1, POPEN_MODE);
     *io_type = lsx_io_pipe;
@@ -384,6 +384,7 @@ static FILE * xfopen(char const * identi
   }
   else if (is_url(identifier)) {
     FILE * f = NULL;
+/* XXX: really folks ? forking a wget process to get an URL.. (!!!!!) */
 #ifdef HAVE_POPEN
     char const * const command_format = "wget --no-check-certificate -q -O- \"%s\"";
     char * command = lsx_malloc(strlen(command_format) + strlen(identifier));
@@ -460,7 +461,7 @@ static sox_format_t * open_read(
 #ifdef HAVE_FMEMOPEN
         buffer? fmemopen(buffer, buffer_size, "rb") :
 #endif
-        xfopen(path, "rb", &ft->io_type);
+        xfopen(path, "rbe", &ft->io_type);
       type = io_types[ft->io_type];
       if (ft->fp == NULL) {
         lsx_fail("can't open input %s `%s': %s", type, path, strerror(errno));
@@ -858,7 +859,7 @@ static sox_format_t * open_write(
         buffer? fmemopen(buffer, buffer_size, "w+b") :
         buffer_ptr? open_memstream(buffer_ptr, buffer_size_ptr) :
 #endif
-        fopen(path, "w+b");
+        fopen(path, "w+be");
       if (ft->fp == NULL) {
         lsx_fail("can't open output file `%s': %s", path, strerror(errno));
         goto error;
@@ -1068,7 +1069,7 @@ int sox_parse_playlist(sox_playlist_call
   char * dirname = lsx_strdup(listname);
   char * slash_pos = LAST_SLASH(dirname);
   lsx_io_type io_type;
-  FILE * file = xfopen(listname, "r", &io_type);
+  FILE * file = xfopen(listname, "re", &io_type);
   char * filename;
   int c, result = SOX_SUCCESS;
 
--- src/libsox_i.c.orig
+++ src/libsox_i.c
@@ -34,7 +34,7 @@
 #else
   #define MKTEMP_X 0
 #endif
-
+#include <fcntl.h>
 #ifndef HAVE_MKSTEMP
   #include <fcntl.h>
   #include <sys/types.h>
@@ -99,7 +99,7 @@ FILE * lsx_tmpfile(void)
     int fildes;
     strcpy(name, path);
     strcat(name, end);
-    fildes = mkstemp(name);
+    fildes = mkostemp(name, O_CLOEXEC);
 #ifdef HAVE_UNISTD_H
     lsx_debug(FAKE_MKSTEMP "mkstemp, name=%s (unlinked)", name);
     unlink(name);
@@ -107,7 +107,7 @@ FILE * lsx_tmpfile(void)
     lsx_debug(FAKE_MKSTEMP "mkstemp, name=%s (O_TEMPORARY)", name);
 #endif
     free(name);
-    return fildes == -1? NULL : fdopen(fildes, "w+");
+    return fildes == -1? NULL : fdopen(fildes, "w+e");
   }
 
   /* Use standard tmpfile (delete on close); tmp dir is undefined: */
--- src/noiseprof.c.orig
+++ src/noiseprof.c
@@ -75,7 +75,7 @@ static int sox_noiseprof_start(sox_effec
     effp->global_info->global_info->stdout_in_use_by = effp->handler.name;
     data->output_file = stdout;
   }
-  else if ((data->output_file = fopen(data->output_filename, "w")) == NULL) {
+  else if ((data->output_file = fopen(data->output_filename, "we")) == NULL) {
     lsx_fail("Couldn't open profile file %s: %s", data->output_filename, strerror(errno));
     return SOX_EOF;
   }
--- src/sox.c.orig
+++ src/sox.c
@@ -906,7 +906,7 @@ static char * * strtoargv(char * s, int
 
 static void read_user_effects(char const *filename)
 {
-    FILE *file = fopen(filename, "rt");
+    FILE *file = fopen(filename, "rte");
     const size_t buffer_size_step = 1024;
     size_t buffer_size = buffer_size_step;
     char *s = lsx_malloc(buffer_size); /* buffer for one input line */
@@ -1293,7 +1293,7 @@ static int kbhit(void)
 static void adjust_volume(int delta)
 {
   char * from_env = getenv("MIXERDEV");
-  int vol1 = 0, vol2 = 0, fd = open(from_env? from_env : "/dev/mixer", O_RDWR);
+  int vol1 = 0, vol2 = 0, fd = open(from_env? from_env : "/dev/mixer", O_RDWR|O_CLOEXEC);
   if (fd >= 0) {
     if (ioctl(fd, MIXER_READ(SOUND_MIXER_PCM), &vol1) != -1) {
       int side1 = vol1 & 0xff, side2 = (vol1 >> 8) & 0xff;
@@ -2123,7 +2123,7 @@ static void read_comment_file(sox_commen
   int c;
   size_t text_length = 100;
   char * text = lsx_malloc(text_length + 1);
-  FILE * file = fopen(filename, "rt");
+  FILE * file = fopen(filename, "rte");
 
   if (file == NULL) {
     lsx_fail("Cannot open comment file `%s'", filename);
--- src/spectrogram.c.orig
+++ src/spectrogram.c
@@ -492,7 +492,7 @@ static int axis(double to, int max_steps
 static int stop(sox_effect_t * effp)
 {
   priv_t *    p        = (priv_t *) effp->priv;
-  FILE *      file     = fopen(p->out_name, "wb");
+  FILE *      file     = fopen(p->out_name, "wbe");
   uLong       font_len = 96 * font_y;
   int         chans    = effp->in_signal.channels;
   int         c_rows   = p->rows * chans + chans - 1;
--- configure.ac.orig
+++ configure.ac
@@ -16,7 +16,9 @@ dnl Check we have the right srcdir
 AC_CONFIG_SRCDIR(sox.1)
 
 dnl Checks for programs.
-AC_PROG_CC
+AC_PROG_CC_STDC
+AC_USE_SYSTEM_EXTENSIONS
+AC_SYS_LARGEFILE
 AM_PROG_CC_C_O
 AC_PROG_INSTALL
 AC_PROG_LN_S
@@ -155,7 +157,6 @@ if test "$ac_cv_func_pow" = no; then
 fi
 
 dnl Large File Support
-AC_SYS_LARGEFILE
 AC_FUNC_FSEEKO
 if test "$ac_cv_sys_file_offset_bits" = "64"; then
   dnl This is either a 64-bit platform or a 32-bit platform
--- src/Makefile.am.orig
+++ src/Makefile.am
@@ -2,7 +2,7 @@
 
 RM = rm -f 
 
-AM_CPPFLAGS = -DLADSPA_PATH="\"@LADSPA_PATH@\""
+AM_CPPFLAGS = -include $(top_builddir)/src/soxconfig.h -DLADSPA_PATH="\"@LADSPA_PATH@\""
 AM_CFLAGS = @WARN_CFLAGS@ #-Werror
 
 if HAVE_LIBLTDL
@@ -12,7 +12,7 @@ if HAVE_LIBLTDL
 # is ignored when you specify a more specific one.
 # We want to version libsox and we are OK because they
 # have a more specific LDFLAGS that includes -version-info.
-AM_LDFLAGS = -avoid-version -module
+AM_LDFLAGS = -avoid-version -module -shared -export-dynamic
 AM_CPPFLAGS += -DPKGLIBDIR="\"$(pkglibdir)\""
 endif
 if HAVE_WIN32_LTDL
@@ -95,7 +95,7 @@ libsox_la_LIBADD += @GOMP_LIBS@
 endif
 
 libsox_la_CFLAGS = @WARN_CFLAGS@
-libsox_la_LDFLAGS = @APP_LDFLAGS@ -version-info @SHLIB_VERSION@
+libsox_la_LDFLAGS = @APP_LDFLAGS@ -no-undefined -version-info @SHLIB_VERSION@
 
 if HAVE_WIN32_LTDL
   libsox_la_SOURCES += win32-ltdl.c win32-ltdl.h
--- src/sox_i.h.orig
+++ src/sox_i.h
@@ -17,8 +17,10 @@
 #include "sox.h"
 
 #if defined HAVE_FMEMOPEN
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
+#endif
 
 #include <errno.h>
 #include <stdio.h>
--- lpc10/Makefile.am.orig
+++ lpc10/Makefile.am
@@ -12,7 +12,7 @@ liblpc10_la_SOURCES = analys.c bsynz.c c
   ham84.c hp100.c invert.c irc2pc.c ivfilt.c lpcdec.c lpcenc.c lpcini.c \
   lpfilt.c median.c mload.c onset.c pitsyn.c placea.c placev.c preemp.c \
   prepro.c random.c rcchk.c synths.c tbdm.c voicin.c vparms.c
-AM_CPPFLAGS=-I../src
+AM_CPPFLAGS= -include $(top_builddir)/src/soxconfig.h -I../src
 if HAVE_LIBLTDL
 AM_LDFLAGS=-avoid-version -module
 endif