From 5b57aa6aa39062a3e84f4f65693db287aeedadfd Mon Sep 17 00:00:00 2001 From: Roman Kollar Date: Oct 29 2012 16:40:42 +0000 Subject: Fix casting in lseek calls in the history file locking patch --- diff --git a/tcsh-6.18.00-history-file-locking.patch b/tcsh-6.18.00-history-file-locking.patch index 01b6102..c96fa5f 100644 --- a/tcsh-6.18.00-history-file-locking.patch +++ b/tcsh-6.18.00-history-file-locking.patch @@ -1,6 +1,6 @@ -From e59f1ed7c4a23b7b72eb45b57909266e7c20a780 Mon Sep 17 00:00:00 2001 -From: "Vojtech Vitek (V-Teq)" -Date: Wed, 16 May 2012 19:07:09 +0200 +From 6267f930ac9afead0f9f53122c63ceada9deb546 Mon Sep 17 00:00:00 2001 +From: Roman Kollar +Date: Mon, 29 Oct 2012 17:38:10 +0100 Subject: [PATCH] Add .history file locking - shared readers, exclusive writer 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) --- - sh.c | 103 +++++++++++++++++++++++++++++++++-------------- - sh.decls.h | 5 +- - sh.dir.c | 2 +- - sh.dol.c | 2 +- - sh.err.c | 16 +++++++ - sh.h | 18 ++++++++ - sh.hist.c | 131 ++++++++++++++++++++++++++++++------------------------------ - sh.lex.c | 8 ++-- - sh.sem.c | 2 +- - 9 files changed, 183 insertions(+), 104 deletions(-) + sh.c | 101 +++++++++++++++++++++++++++++++++-------------- + sh.decls.h | 5 ++- + sh.dir.c | 2 +- + sh.dol.c | 2 +- + sh.err.c | 16 ++++++++ + sh.h | 18 +++++++++ + sh.hist.c | 131 +++++++++++++++++++++++++++++++------------------------------ + sh.lex.c | 8 ++-- + sh.sem.c | 2 +- + 9 files changed, 182 insertions(+), 103 deletions(-) diff --git a/sh.c b/sh.c -index 77e75cb..febcad9 100644 +index dcd9116..5d90492 100644 --- a/sh.c +++ b/sh.c @@ -140,6 +140,7 @@ struct saved_state { @@ -219,11 +219,10 @@ index 77e75cb..febcad9 100644 xfree(f); t = glob_all_or_error(t); - if ((!srcfile(file, 0, hflg, t)) && (!hflg) && (!bequiet)) -- stderror(ERR_SYSTEM, file, strerror(errno)); -- cleanup_until(file); + fd = srcfile(file, 0, (flg | newflg), t); + 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 + * 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 -index cd13288..d45c599 100644 +index db90288..d4332f3 100644 --- a/sh.decls.h +++ b/sh.decls.h @@ -37,7 +37,7 @@ @@ -265,7 +264,7 @@ index cd13288..d45c599 100644 /* diff --git a/sh.dir.c b/sh.dir.c -index 058bc27..cf3b349 100644 +index ab89855..4bfe430 100644 --- a/sh.dir.c +++ b/sh.dir.c @@ -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 -index 5df8c60..7db7b60 100644 +index 45b10e0..2ce7cb5 100644 --- a/sh.dol.c +++ b/sh.dol.c @@ -1110,6 +1110,6 @@ again: @@ -286,11 +285,11 @@ index 5df8c60..7db7b60 100644 tmp = short2str(obuf); (void) xwrite(0, tmp, strlen (tmp)); - (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); } diff --git a/sh.err.c b/sh.err.c -index d8574cd..85093fa 100644 +index e157d6a..29d41c3 100644 --- a/sh.err.c +++ b/sh.err.c @@ -514,6 +514,22 @@ open_cleanup(void *xptr) @@ -317,7 +316,7 @@ index d8574cd..85093fa 100644 { DIR *dir; diff --git a/sh.h b/sh.h -index 88f7e90..1d13322 100644 +index 691add3..4e3f13c 100644 --- a/sh.h +++ b/sh.h @@ -50,6 +50,24 @@ @@ -346,7 +345,7 @@ index 88f7e90..1d13322 100644 typedef unsigned long intptr_t; #endif diff --git a/sh.hist.c b/sh.hist.c -index 2482a13..4b4aa10 100644 +index 6a12737..bd26091 100644 --- a/sh.hist.c +++ b/sh.hist.c @@ -44,14 +44,6 @@ Char HistLit = 0; @@ -583,7 +582,7 @@ index 2482a13..4b4aa10 100644 + if (fd > 0) { + /* Truncate the .history file. */ + (void) ftruncate(fd, 0); -+ (void) lseek(fd, 0, SEEK_SET); ++ (void) lseek(fd, (off_t) 0, SEEK_SET); + } + } + if (fd <= 0) { @@ -647,7 +646,7 @@ index 2482a13..4b4aa10 100644 + return fd; /* Valid/invalid file descriptor (>FSAVE, -1). Zero on error. */ } diff --git a/sh.lex.c b/sh.lex.c -index 08520dd..a87559d 100644 +index 80643f7..57ec7a9 100644 --- a/sh.lex.c +++ b/sh.lex.c @@ -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 */ err = errno; - lseek(fildes, -(off_t)partial, L_INCR); -+ lseek(fildes, -partial, SEEK_CUR); ++ lseek(fildes, -(off_t)partial, SEEK_CUR); errno = err; return res != 0 ? res : r; } @@ -673,7 +672,7 @@ index 08520dd..a87559d 100644 btoeof(void) { - (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; fseekp = feobp; alvec = NULL; @@ -682,12 +681,12 @@ index 08520dd..a87559d 100644 if (arginp || onelflg || intty) return; - 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; fbuf = xcalloc(2, sizeof(Char **)); fblocks = 1; diff --git a/sh.sem.c b/sh.sem.c -index 99cd83c..92bef5d 100644 +index c880974..bc51b50 100644 --- a/sh.sem.c +++ b/sh.sem.c @@ -892,7 +892,7 @@ doio(struct command *t, int *pipein, int *pipeout) @@ -695,10 +694,10 @@ index 99cd83c..92bef5d 100644 #else /* !O_APPEND */ fd = xopen(tmp, O_WRONLY|O_LARGEFILE); - (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 */ } else -- -1.7.7.6 +1.7.11.7 diff --git a/tcsh.spec b/tcsh.spec index 22ac91e..54cac29 100644 --- a/tcsh.spec +++ b/tcsh.spec @@ -121,6 +121,7 @@ fi * Mon Oct 29 2012 Roman Kollar - 6.18.00-4 - Add Copyright file in %doc - 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 - 6.18.00-3 - Drop tcsh-6.18.00-history-file-locking.patch for now (bug 842851)