You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
153 lines
4.5 KiB
153 lines
4.5 KiB
7 years ago
|
diff --git a/lib/rmt.h b/lib/rmt.h
|
||
|
index 2ce9dc5..4580e49 100644
|
||
|
--- a/lib/rmt.h
|
||
|
+++ b/lib/rmt.h
|
||
|
@@ -17,8 +17,9 @@
|
||
|
along with this program; if not, write to the Free Software Foundation,
|
||
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||
|
|
||
|
-extern char *rmt_command;
|
||
|
-extern char *rmt_dev_name__;
|
||
|
+/* upstream fix 0b3d84a0ee */
|
||
|
+extern char const *rmt_command;
|
||
|
+extern char const *rmt_dev_name__;
|
||
|
|
||
|
int rmt_open__ (const char *, int, int, const char *);
|
||
|
int rmt_close__ (int);
|
||
|
diff --git a/lib/rtapelib.c b/lib/rtapelib.c
|
||
|
index 3aee428..1cef0fc 100644
|
||
|
--- a/lib/rtapelib.c
|
||
|
+++ b/lib/rtapelib.c
|
||
|
@@ -90,10 +90,10 @@ static int from_remote[MAXUNIT][2] = {{-1, -1}, {-1, -1}, {-1, -1}, {-1, -1}};
|
||
|
/* The pipes for sending data to remote tape drives. */
|
||
|
static int to_remote[MAXUNIT][2] = {{-1, -1}, {-1, -1}, {-1, -1}, {-1, -1}};
|
||
|
|
||
|
-char *rmt_command = DEFAULT_RMT_COMMAND;
|
||
|
+char const *rmt_command = DEFAULT_RMT_COMMAND; /* upstream fix 0b3d84a0ee */
|
||
|
|
||
|
/* Temporary variable used by macros in rmt.h. */
|
||
|
-char *rmt_dev_name__;
|
||
|
+char const *rmt_dev_name__; /* upstream fix 0b3d84a0ee */
|
||
|
|
||
|
/* If true, always consider file names to be local, even if they contain
|
||
|
colons */
|
||
|
@@ -490,15 +490,17 @@ rmt_open__ (const char *file_name, int open_mode, int bias,
|
||
|
{
|
||
|
/* Child. */
|
||
|
|
||
|
- close (STDIN_FILENO);
|
||
|
- dup (to_remote[remote_pipe_number][PREAD]);
|
||
|
- close (to_remote[remote_pipe_number][PREAD]);
|
||
|
- close (to_remote[remote_pipe_number][PWRITE]);
|
||
|
-
|
||
|
- close (STDOUT_FILENO);
|
||
|
- dup (from_remote[remote_pipe_number][PWRITE]);
|
||
|
- close (from_remote[remote_pipe_number][PREAD]);
|
||
|
- close (from_remote[remote_pipe_number][PWRITE]);
|
||
|
+ /* upstream fix 0b3d84a0ee */
|
||
|
+ if (dup2 (to_remote[remote_pipe_number][PREAD], STDIN_FILENO) < 0
|
||
|
+ || (to_remote[remote_pipe_number][PREAD] != STDIN_FILENO
|
||
|
+ && close (to_remote[remote_pipe_number][PREAD]) != 0)
|
||
|
+ || (to_remote[remote_pipe_number][PWRITE] != STDIN_FILENO
|
||
|
+ && close (to_remote[remote_pipe_number][PWRITE]) != 0)
|
||
|
+ || dup2 (from_remote[remote_pipe_number][PWRITE], STDOUT_FILENO) < 0
|
||
|
+ || close (from_remote[remote_pipe_number][PREAD]) != 0
|
||
|
+ || close (from_remote[remote_pipe_number][PWRITE]) != 0)
|
||
|
+ error (EXIT_ON_EXEC_ERROR, errno,
|
||
|
+ _("Cannot redirect files for remote shell"));
|
||
|
|
||
|
sys_reset_uid_gid ();
|
||
|
|
||
|
diff --git a/lib/system.h b/lib/system.h
|
||
|
index 2deb585..599d4ba 100644
|
||
|
--- a/lib/system.h
|
||
|
+++ b/lib/system.h
|
||
|
@@ -471,8 +471,13 @@ char *getenv ();
|
||
|
# define SET_BINARY_MODE(arc)
|
||
|
# define ERRNO_IS_EACCES 0
|
||
|
# define TTY_NAME "/dev/tty"
|
||
|
-# define sys_reset_uid_gid() \
|
||
|
- do { setuid (getuid ()); setgid (getgid ()); } while (0)
|
||
|
+
|
||
|
+/* upstream fix 0b3d84a0ee */
|
||
|
+# define sys_reset_uid_gid() \
|
||
|
+ do { \
|
||
|
+ if (! (setuid (getuid ()) == 0 && setgid (getgid ()) == 0)) \
|
||
|
+ abort (); \
|
||
|
+ } while (0)
|
||
|
#endif
|
||
|
|
||
|
#if XENIX
|
||
|
diff --git a/src/compare.c b/src/compare.c
|
||
|
index 273269a..796d7aa 100644
|
||
|
--- a/src/compare.c
|
||
|
+++ b/src/compare.c
|
||
|
@@ -362,7 +362,7 @@ static void
|
||
|
diff_dumpdir (void)
|
||
|
{
|
||
|
const char *dumpdir_buffer;
|
||
|
- dev_t dev = 0;
|
||
|
+ /* upstream fix 5bb04335079 */
|
||
|
struct stat stat_data;
|
||
|
|
||
|
if (deref_stat (current_stat_info.file_name, &stat_data) != 0)
|
||
|
@@ -372,8 +372,7 @@ diff_dumpdir (void)
|
||
|
else
|
||
|
stat_error (current_stat_info.file_name);
|
||
|
}
|
||
|
- else
|
||
|
- dev = stat_data.st_dev;
|
||
|
+ /* upstream fix 5bb04335079 */
|
||
|
|
||
|
dumpdir_buffer = directory_contents (scan_directory (¤t_stat_info));
|
||
|
|
||
|
diff --git a/tests/genfile.c b/tests/genfile.c
|
||
|
index 8541be6..fa480ef 100644
|
||
|
--- a/tests/genfile.c
|
||
|
+++ b/tests/genfile.c
|
||
|
@@ -485,9 +485,11 @@ generate_files_from_list ()
|
||
|
static void
|
||
|
mkhole (int fd, off_t displ)
|
||
|
{
|
||
|
- if (lseek (fd, displ, SEEK_CUR) == -1)
|
||
|
+ off_t offset = lseek (fd, displ, SEEK_CUR);
|
||
|
+ if (offset < 0)
|
||
|
error (EXIT_FAILURE, errno, "lseek");
|
||
|
- ftruncate (fd, lseek (fd, 0, SEEK_CUR));
|
||
|
+ if (ftruncate (fd, offset) != 0)
|
||
|
+ error (EXIT_FAILURE, errno, "ftruncate");
|
||
|
}
|
||
|
|
||
|
static void
|
||
|
@@ -685,13 +687,18 @@ exec_checkpoint (struct action *p)
|
||
|
error (0, errno, _("cannot open `%s'"), p->name);
|
||
|
break;
|
||
|
}
|
||
|
- ftruncate (fd, p->size);
|
||
|
+ if (ftruncate (fd, p->size) != 0)
|
||
|
+ {
|
||
|
+ error (0, errno, _("cannot truncate `%s'"), p->name);
|
||
|
+ break;
|
||
|
+ }
|
||
|
close (fd);
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case OPT_EXEC:
|
||
|
- system (p->name);
|
||
|
+ if (system (p->name) != 0)
|
||
|
+ error (0, 0, _("command failed: %s"), p->name);
|
||
|
break;
|
||
|
|
||
|
case OPT_UNLINK:
|
||
|
@@ -761,7 +768,8 @@ exec_command (void)
|
||
|
signal (SIGCHLD, SIG_DFL);
|
||
|
#endif
|
||
|
|
||
|
- pipe (fd);
|
||
|
+ if (pipe (fd) != 0)
|
||
|
+ error (EXIT_FAILURE, errno, "pipe");
|
||
|
|
||
|
pid = fork ();
|
||
|
if (pid == -1)
|