X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=lib%2Frtapelib.c;h=3aee42865398af40ddb4ef6f7fd47d668f517e88;hb=1a44d77d50f4fb37c0410eed04b82303624ea2ec;hp=51faf3ce91dbd50496705ff15338e87d58c39466;hpb=138fc7e67e3d9845cd7d81aad0e9c7724784f9b9;p=debian%2Ftar diff --git a/lib/rtapelib.c b/lib/rtapelib.c index 51faf3ce..3aee4286 100644 --- a/lib/rtapelib.c +++ b/lib/rtapelib.c @@ -121,7 +121,7 @@ do_command (int handle, const char *buffer) /* Save the current pipe handler and try to make the request. */ size_t length = strlen (buffer); - RETSIGTYPE (*pipe_handler) () = signal (SIGPIPE, SIG_IGN); + RETSIGTYPE (*pipe_handler) (int) = signal (SIGPIPE, SIG_IGN); ssize_t written = full_write (WRITE_SIDE (handle), buffer, length); signal (SIGPIPE, pipe_handler); @@ -425,6 +425,9 @@ rmt_open__ (const char *file_name, int open_mode, int bias, } /* FIXME: Should somewhat validate the decoding, here. */ + if (gethostbyname (remote_host) == NULL) + error (EXIT_ON_EXEC_ERROR, 0, _("Cannot connect to %s: resolve failed"), + remote_host); if (remote_user && *remote_user == '\0') remote_user = 0; @@ -570,7 +573,8 @@ rmt_read__ (int handle, char *buffer, size_t length) sprintf (command_buffer, "R%lu\n", (unsigned long) length); if (do_command (handle, command_buffer) == -1 - || (status = get_status (handle)) == SAFE_READ_ERROR) + || (status = get_status (handle)) == SAFE_READ_ERROR + || status > length) return SAFE_READ_ERROR; for (counter = 0; counter < status; counter += rlen, buffer += rlen) @@ -592,7 +596,7 @@ size_t rmt_write__ (int handle, char *buffer, size_t length) { char command_buffer[COMMAND_BUFFER_SIZE]; - RETSIGTYPE (*pipe_handler) (); + RETSIGTYPE (*pipe_handler) (int); size_t written; sprintf (command_buffer, "W%lu\n", (unsigned long) length); @@ -706,6 +710,12 @@ rmt_ioctl__ (int handle, int operation, char *argument) || (status = get_status (handle), status == -1)) return -1; + if (status > sizeof (struct mtop)) + { + errno = EOVERFLOW; + return -1; + } + for (; status > 0; status -= counter, argument += counter) { counter = safe_read (READ_SIDE (handle), argument, status);