]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Don't fdopen() in append mode in cc_file.c 236/head
authorBen Kaduk <kaduk@mit.edu>
Mon, 24 Nov 2014 23:23:32 +0000 (18:23 -0500)
committerBen Kaduk <kaduk@mit.edu>
Sat, 29 Nov 2014 21:22:59 +0000 (16:22 -0500)
Implementations of fdopen() are inconsistent about the state of
the file offset after fdopen(., "a+") -- some position the stream
at the end of the file immediately (e.g., Solaris), for both reading
and writing, but others let reads occur from the beginning of the
file (e.g., glibc).

As it turns out, we only ever write to the file descriptor, not
through stdio, so opening the file with O_APPEND and using fdopen()
with "r+b" should give us sufficient append semantics, while
more portably letting the stream read from the beginning of the file.

This fixes the test suite on Solaris, a regression introduced
by commit 6979ead5e5c24ca0ec3569eb4bef48c2e5d8a726.

ticket: 8026

src/lib/krb5/ccache/cc_file.c

index e220971a7f8426350e6b092f4f64f4e84c0459c7..295f959f04d12d0775d7ea2b3ae245a1a99fba01 100644 (file)
@@ -348,7 +348,7 @@ open_cache_file(krb5_context context, const char *filename,
         return ret;
     }
 
-    fp = fdopen(fd, writable ? "a+b" : "rb");
+    fp = fdopen(fd, writable ? "r+b" : "rb");
     if (fp == NULL) {
         (void)krb5_unlock_file(context, fd);
         (void)close(fd);