Fix casting in lseek calls in the history file locking patch
This commit is contained in:
		
							parent
							
								
									52c2a65744
								
							
						
					
					
						commit
						5b57aa6aa3
					
				| @ -1,6 +1,6 @@ | |||||||
| From e59f1ed7c4a23b7b72eb45b57909266e7c20a780 Mon Sep 17 00:00:00 2001 | From 6267f930ac9afead0f9f53122c63ceada9deb546 Mon Sep 17 00:00:00 2001 | ||||||
| From: "Vojtech Vitek (V-Teq)" <vvitek@redhat.com> | From: Roman Kollar <rkollar@redhat.com> | ||||||
| Date: Wed, 16 May 2012 19:07:09 +0200 | Date: Mon, 29 Oct 2012 17:38:10 +0100 | ||||||
| Subject: [PATCH] Add .history file locking - shared readers, exclusive writer | Subject: [PATCH] Add .history file locking - shared readers, exclusive writer | ||||||
| 
 | 
 | ||||||
| Originally reported at Red Hat Bugzilla: | Originally reported at Red Hat Bugzilla: | ||||||
| @ -8,19 +8,19 @@ https://bugzilla.redhat.com/show_bug.cgi?id=648592 | |||||||
| 
 | 
 | ||||||
| Patch by Vojtech Vitek (V-Teq) <vvitek@redhat.com> | Patch by Vojtech Vitek (V-Teq) <vvitek@redhat.com> | ||||||
| ---
 | ---
 | ||||||
|  sh.c       |  103 +++++++++++++++++++++++++++++++++-------------- |  sh.c       | 101 +++++++++++++++++++++++++++++++++-------------- | ||||||
|  sh.decls.h |    5 +- |  sh.decls.h |   5 ++- | ||||||
|  sh.dir.c   |   2 +- |  sh.dir.c   |   2 +- | ||||||
|  sh.dol.c   |   2 +- |  sh.dol.c   |   2 +- | ||||||
|  sh.err.c   |   16 +++++++ |  sh.err.c   |  16 ++++++++ | ||||||
|  sh.h       |   18 ++++++++ |  sh.h       |  18 +++++++++ | ||||||
|  sh.hist.c  |  131 ++++++++++++++++++++++++++++++------------------------------ |  sh.hist.c  | 131 +++++++++++++++++++++++++++++++------------------------------ | ||||||
|  sh.lex.c   |   8 ++-- |  sh.lex.c   |   8 ++-- | ||||||
|  sh.sem.c   |   2 +- |  sh.sem.c   |   2 +- | ||||||
|  9 files changed, 183 insertions(+), 104 deletions(-) |  9 files changed, 182 insertions(+), 103 deletions(-) | ||||||
| 
 | 
 | ||||||
| diff --git a/sh.c b/sh.c
 | diff --git a/sh.c b/sh.c
 | ||||||
| index 77e75cb..febcad9 100644
 | index dcd9116..5d90492 100644
 | ||||||
| --- a/sh.c
 | --- a/sh.c
 | ||||||
| +++ b/sh.c
 | +++ b/sh.c
 | ||||||
| @@ -140,6 +140,7 @@ struct saved_state {
 | @@ -140,6 +140,7 @@ struct saved_state {
 | ||||||
| @ -219,11 +219,10 @@ index 77e75cb..febcad9 100644 | |||||||
|      xfree(f); |      xfree(f); | ||||||
|      t = glob_all_or_error(t); |      t = glob_all_or_error(t); | ||||||
| -    if ((!srcfile(file, 0, hflg, t)) && (!hflg) && (!bequiet))
 | -    if ((!srcfile(file, 0, hflg, t)) && (!hflg) && (!bequiet))
 | ||||||
| -	stderror(ERR_SYSTEM, file, strerror(errno));
 |  | ||||||
| -    cleanup_until(file);
 |  | ||||||
| +    fd = srcfile(file, 0, (flg | newflg), t);
 | +    fd = srcfile(file, 0, (flg | newflg), t);
 | ||||||
| +    if ((!fd) && (!newflg) && (!bequiet))
 | +    if ((!fd) && (!newflg) && (!bequiet))
 | ||||||
| +	stderror(ERR_SYSTEM, f, strerror(errno));
 |  	stderror(ERR_SYSTEM, file, strerror(errno)); | ||||||
|  | -    cleanup_until(file);
 | ||||||
| +
 | +
 | ||||||
| +    /* We need to preserve fd and it's cleaning routines on the top of the
 | +    /* We need to preserve fd and it's cleaning routines on the top of the
 | ||||||
| +     * cleaning stack. Don't call cleanup_until() but clean it manually. */
 | +     * cleaning stack. Don't call cleanup_until() but clean it manually. */
 | ||||||
| @ -235,7 +234,7 @@ index 77e75cb..febcad9 100644 | |||||||
|   |   | ||||||
|  /* |  /* | ||||||
| diff --git a/sh.decls.h b/sh.decls.h
 | diff --git a/sh.decls.h b/sh.decls.h
 | ||||||
| index cd13288..d45c599 100644
 | index db90288..d4332f3 100644
 | ||||||
| --- a/sh.decls.h
 | --- a/sh.decls.h
 | ||||||
| +++ b/sh.decls.h
 | +++ b/sh.decls.h
 | ||||||
| @@ -37,7 +37,7 @@
 | @@ -37,7 +37,7 @@
 | ||||||
| @ -265,7 +264,7 @@ index cd13288..d45c599 100644 | |||||||
|   |   | ||||||
|  /* |  /* | ||||||
| diff --git a/sh.dir.c b/sh.dir.c
 | diff --git a/sh.dir.c b/sh.dir.c
 | ||||||
| index 058bc27..cf3b349 100644
 | index ab89855..4bfe430 100644
 | ||||||
| --- a/sh.dir.c
 | --- a/sh.dir.c
 | ||||||
| +++ b/sh.dir.c
 | +++ b/sh.dir.c
 | ||||||
| @@ -1342,7 +1342,7 @@ loaddirs(Char *fname)
 | @@ -1342,7 +1342,7 @@ loaddirs(Char *fname)
 | ||||||
| @ -278,7 +277,7 @@ index 058bc27..cf3b349 100644 | |||||||
|  } |  } | ||||||
|   |   | ||||||
| diff --git a/sh.dol.c b/sh.dol.c
 | diff --git a/sh.dol.c b/sh.dol.c
 | ||||||
| index 5df8c60..7db7b60 100644
 | index 45b10e0..2ce7cb5 100644
 | ||||||
| --- a/sh.dol.c
 | --- a/sh.dol.c
 | ||||||
| +++ b/sh.dol.c
 | +++ b/sh.dol.c
 | ||||||
| @@ -1110,6 +1110,6 @@ again:
 | @@ -1110,6 +1110,6 @@ again:
 | ||||||
| @ -286,11 +285,11 @@ index 5df8c60..7db7b60 100644 | |||||||
|      tmp = short2str(obuf); |      tmp = short2str(obuf); | ||||||
|      (void) xwrite(0, tmp, strlen (tmp)); |      (void) xwrite(0, tmp, strlen (tmp)); | ||||||
| -    (void) lseek(0, (off_t) 0, L_SET);
 | -    (void) lseek(0, (off_t) 0, L_SET);
 | ||||||
| +    (void) lseek(0, 0, SEEK_SET);
 | +    (void) lseek(0, (off_t) 0, SEEK_SET);
 | ||||||
|      cleanup_until(&inheredoc); |      cleanup_until(&inheredoc); | ||||||
|  } |  } | ||||||
| diff --git a/sh.err.c b/sh.err.c
 | diff --git a/sh.err.c b/sh.err.c
 | ||||||
| index d8574cd..85093fa 100644
 | index e157d6a..29d41c3 100644
 | ||||||
| --- a/sh.err.c
 | --- a/sh.err.c
 | ||||||
| +++ b/sh.err.c
 | +++ b/sh.err.c
 | ||||||
| @@ -514,6 +514,22 @@ open_cleanup(void *xptr)
 | @@ -514,6 +514,22 @@ open_cleanup(void *xptr)
 | ||||||
| @ -317,7 +316,7 @@ index d8574cd..85093fa 100644 | |||||||
|  { |  { | ||||||
|      DIR *dir; |      DIR *dir; | ||||||
| diff --git a/sh.h b/sh.h
 | diff --git a/sh.h b/sh.h
 | ||||||
| index 88f7e90..1d13322 100644
 | index 691add3..4e3f13c 100644
 | ||||||
| --- a/sh.h
 | --- a/sh.h
 | ||||||
| +++ b/sh.h
 | +++ b/sh.h
 | ||||||
| @@ -50,6 +50,24 @@
 | @@ -50,6 +50,24 @@
 | ||||||
| @ -346,7 +345,7 @@ index 88f7e90..1d13322 100644 | |||||||
|  typedef unsigned long intptr_t; |  typedef unsigned long intptr_t; | ||||||
|  #endif |  #endif | ||||||
| diff --git a/sh.hist.c b/sh.hist.c
 | diff --git a/sh.hist.c b/sh.hist.c
 | ||||||
| index 2482a13..4b4aa10 100644
 | index 6a12737..bd26091 100644
 | ||||||
| --- a/sh.hist.c
 | --- a/sh.hist.c
 | ||||||
| +++ b/sh.hist.c
 | +++ b/sh.hist.c
 | ||||||
| @@ -44,14 +44,6 @@ Char HistLit = 0;
 | @@ -44,14 +44,6 @@ Char HistLit = 0;
 | ||||||
| @ -583,7 +582,7 @@ index 2482a13..4b4aa10 100644 | |||||||
| +	if (fd > 0) {
 | +	if (fd > 0) {
 | ||||||
| +	    /* Truncate the .history file. */
 | +	    /* Truncate the .history file. */
 | ||||||
| +	    (void) ftruncate(fd, 0);
 | +	    (void) ftruncate(fd, 0);
 | ||||||
| +	    (void) lseek(fd, 0, SEEK_SET);
 | +	    (void) lseek(fd, (off_t) 0, SEEK_SET);
 | ||||||
| +	}
 | +	}
 | ||||||
| +    }
 | +    }
 | ||||||
| +    if (fd <= 0) {
 | +    if (fd <= 0) {
 | ||||||
| @ -647,7 +646,7 @@ index 2482a13..4b4aa10 100644 | |||||||
| +    return fd; /* Valid/invalid file descriptor (>FSAVE, -1). Zero on error. */
 | +    return fd; /* Valid/invalid file descriptor (>FSAVE, -1). Zero on error. */
 | ||||||
|  } |  } | ||||||
| diff --git a/sh.lex.c b/sh.lex.c
 | diff --git a/sh.lex.c b/sh.lex.c
 | ||||||
| index 08520dd..a87559d 100644
 | index 80643f7..57ec7a9 100644
 | ||||||
| --- a/sh.lex.c
 | --- a/sh.lex.c
 | ||||||
| +++ b/sh.lex.c
 | +++ b/sh.lex.c
 | ||||||
| @@ -1595,7 +1595,7 @@ wide_read(int fildes, Char *buf, size_t nchars, int use_fclens)
 | @@ -1595,7 +1595,7 @@ wide_read(int fildes, Char *buf, size_t nchars, int use_fclens)
 | ||||||
| @ -655,7 +654,7 @@ index 08520dd..a87559d 100644 | |||||||
|         stream is not seekable */ |         stream is not seekable */ | ||||||
|      err = errno; |      err = errno; | ||||||
| -    lseek(fildes, -(off_t)partial, L_INCR);
 | -    lseek(fildes, -(off_t)partial, L_INCR);
 | ||||||
| +    lseek(fildes, -partial, SEEK_CUR);
 | +    lseek(fildes, -(off_t)partial, SEEK_CUR);
 | ||||||
|      errno = err; |      errno = err; | ||||||
|      return res != 0 ? res : r; |      return res != 0 ? res : r; | ||||||
|  } |  } | ||||||
| @ -673,7 +672,7 @@ index 08520dd..a87559d 100644 | |||||||
|  btoeof(void) |  btoeof(void) | ||||||
|  { |  { | ||||||
| -    (void) lseek(SHIN, (off_t) 0, L_XTND);
 | -    (void) lseek(SHIN, (off_t) 0, L_XTND);
 | ||||||
| +    (void) lseek(SHIN, 0, SEEK_END);
 | +    (void) lseek(SHIN, (off_t) 0, SEEK_END);
 | ||||||
|      aret = TCSH_F_SEEK; |      aret = TCSH_F_SEEK; | ||||||
|      fseekp = feobp; |      fseekp = feobp; | ||||||
|      alvec = NULL; |      alvec = NULL; | ||||||
| @ -682,12 +681,12 @@ index 08520dd..a87559d 100644 | |||||||
|      if (arginp || onelflg || intty) |      if (arginp || onelflg || intty) | ||||||
|  	return; |  	return; | ||||||
| -    if ((x = lseek(SHIN, (off_t) 0, L_INCR)) == -1)
 | -    if ((x = lseek(SHIN, (off_t) 0, L_INCR)) == -1)
 | ||||||
| +    if ((x = lseek(SHIN, 0, SEEK_CUR)) == -1)
 | +    if ((x = lseek(SHIN, (off_t) 0, SEEK_CUR)) == -1)
 | ||||||
|  	return; |  	return; | ||||||
|      fbuf = xcalloc(2, sizeof(Char **)); |      fbuf = xcalloc(2, sizeof(Char **)); | ||||||
|      fblocks = 1; |      fblocks = 1; | ||||||
| diff --git a/sh.sem.c b/sh.sem.c
 | diff --git a/sh.sem.c b/sh.sem.c
 | ||||||
| index 99cd83c..92bef5d 100644
 | index c880974..bc51b50 100644
 | ||||||
| --- a/sh.sem.c
 | --- a/sh.sem.c
 | ||||||
| +++ b/sh.sem.c
 | +++ b/sh.sem.c
 | ||||||
| @@ -892,7 +892,7 @@ doio(struct command *t, int *pipein, int *pipeout)
 | @@ -892,7 +892,7 @@ doio(struct command *t, int *pipein, int *pipeout)
 | ||||||
| @ -695,10 +694,10 @@ index 99cd83c..92bef5d 100644 | |||||||
|  #else /* !O_APPEND */ |  #else /* !O_APPEND */ | ||||||
|  	    fd = xopen(tmp, O_WRONLY|O_LARGEFILE); |  	    fd = xopen(tmp, O_WRONLY|O_LARGEFILE); | ||||||
| -	    (void) lseek(fd, (off_t) 0, L_XTND);
 | -	    (void) lseek(fd, (off_t) 0, L_XTND);
 | ||||||
| +	    (void) lseek(fd, 0, SEEK_END);
 | +	    (void) lseek(fd, (off_t) 0, SEEK_END);
 | ||||||
|  #endif /* O_APPEND */ |  #endif /* O_APPEND */ | ||||||
|  	} |  	} | ||||||
|  	else |  	else | ||||||
| -- 
 | -- 
 | ||||||
| 1.7.7.6 | 1.7.11.7 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -121,6 +121,7 @@ fi | |||||||
| * Mon Oct 29 2012 Roman Kollar <rkollar@redhat.com> - 6.18.00-4 | * Mon Oct 29 2012 Roman Kollar <rkollar@redhat.com> - 6.18.00-4 | ||||||
| - Add Copyright file in %doc | - Add Copyright file in %doc | ||||||
| - Readd tcsh-6.18.00-history-file-locking.patch | - Readd tcsh-6.18.00-history-file-locking.patch | ||||||
|  | - Fix casting in lseek calls in the history file locking patch (#821796) | ||||||
| 
 | 
 | ||||||
| * Fri Aug 3 2012 Orion Poplawski <orion@nwra.com> - 6.18.00-3 | * Fri Aug 3 2012 Orion Poplawski <orion@nwra.com> - 6.18.00-3 | ||||||
| - Drop tcsh-6.18.00-history-file-locking.patch for now (bug 842851) | - Drop tcsh-6.18.00-history-file-locking.patch for now (bug 842851) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user