ChangeLog, unix.c:

unix.c (PRS): Validate the completion information file descriptor so
  	that the completion bar won't get accidentally written onto the disk.
This commit is contained in:
Theodore Ts'o 2001-05-01 21:13:37 +00:00
parent 5f629b7491
commit ae8160e692
2 changed files with 16 additions and 1 deletions

View File

@ -1,5 +1,9 @@
2001-05-01 Theodore Tso <tytso@valinux.com>
* unix.c (PRS): Validate the completion information file
descriptor so that the completion bar won't get
accidentally written onto the disk.
* e2fsck.8.in: Add explanation that you can use mke2fs -n -b
blocksize to printout alternate superblock locations.

View File

@ -438,7 +438,7 @@ static void signal_progress_off(int sig)
static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
{
int flush = 0;
int c;
int c, fd;
#ifdef MTRACE
extern void *mallwatch;
#endif
@ -483,6 +483,17 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
case 'C':
ctx->progress = e2fsck_update_progress;
ctx->progress_fd = atoi(optarg);
/* Validate the file descriptor to avoid disasters */
fd = dup(ctx->progress_fd);
if (fd < 0) {
fprintf(stderr,
_("Error validating file descriptor %d: %s\n"),
ctx->progress_fd,
error_message(errno));
fatal_error(ctx,
_("Invalid completion information file descriptor"));
} else
close(fd);
break;
case 'p':
case 'a':