summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclIOUtil.c8
-rw-r--r--tests/ioUtil.test23
3 files changed, 34 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index b07f345..393ab83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-12-13 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * generic/tclIOUtil.c (TclGetOpenMode): Only set the O_APPEND flag
+ * tests/ioUtil.test (ioUtil-4.1): on a channel for the 'a'
+ mode and not for 'a+'. [Bug 1773127] (backport from HEAD)
+
2007-12-05 Donal K. Fellows <donal.k.fellows@man.ac.uk>
* generic/tclCmdIL.c (Tcl_LsearchObjCmd): Prevent shimmering crash
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index a587794..aae1e84 100644
--- a/generic/tclIOUtil.c
+++ b/generic/tclIOUtil.c
@@ -17,7 +17,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIOUtil.c,v 1.77.2.34 2007/02/19 23:49:05 hobbs Exp $
+ * RCS: @(#) $Id: tclIOUtil.c,v 1.77.2.35 2007/12/14 02:29:21 hobbs Exp $
*/
#include "tclInt.h"
@@ -1585,7 +1585,11 @@ TclGetOpenMode(interp, string, seekFlagPtr)
return -1;
}
if (string[1] == '+') {
- mode &= ~(O_RDONLY|O_WRONLY);
+ /*
+ * Must remove the O_APPEND flag so that the seek command
+ * works. [Bug 1773127]
+ */
+ mode &= ~(O_RDONLY|O_WRONLY|O_APPEND);
mode |= O_RDWR;
if (string[2] != 0) {
goto error;
diff --git a/tests/ioUtil.test b/tests/ioUtil.test
index 5b0a79e..78df642 100644
--- a/tests/ioUtil.test
+++ b/tests/ioUtil.test
@@ -8,7 +8,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: ioUtil.test,v 1.13.2.1 2003/04/14 15:45:57 vincentdarley Exp $
+# RCS: @(#) $Id: ioUtil.test,v 1.13.2.2 2007/12/14 02:29:22 hobbs Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -303,6 +303,27 @@ test ioUtil-3.8 {TclOpenFileChannelDeleteProc: Verify that all procs have been d
list $err9 $err10 $err11
} {{"TestOpenFileChannelProc1": could not be deleteed} {"TestOpenFileChannelProc2": could not be deleteed} {"TestOpenFileChannelProc3": could not be deleteed}}
+test ioUtil-4.1 {open ... a+ must not use O_APPEND: Bug 1773127} -setup {
+ set f [tcltest::makeFile {} ioutil41.tmp]
+ set fid [open $f w]
+ puts -nonewline $fid 123
+ close $fid
+} -body {
+ set fid [open $f a+]
+ puts -nonewline $fid 456
+ seek $fid 2
+ set d [read $fid 2]
+ seek $fid 4
+ puts -nonewline $fid x
+ close $fid
+ set fid [open $f r]
+ append d [read $fid]
+ close $fid
+ return $d
+} -cleanup {
+ tcltest::removeFile $f
+} -result 341234x6
+
cd $oldpwd
# cleanup