~ubuntu-branches/ubuntu/trusty/eglibc/trusty

« back to all changes in this revision

Viewing changes to debian/patches/any/local-revert-fclose-posix2008.diff

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2013-01-10 18:39:35 UTC
  • mfrom: (1.5.2) (4.4.24 experimental)
  • Revision ID: package-import@ubuntu.com-20130110183935-afsgfxkmg7wk5eaj
Tags: 2.17-0ubuntu1
* Merge with Debian, bringing in a new upstream and many small fixes:
  - patches/any/cvs-malloc-deadlock.diff: Dropped, merged upstream.
  - patches/ubuntu/lddebug-scopes.diff: Rebase for upstream changes.
  - patches/ubuntu/local-CVE-2012-3406.diff: Rebased against upstream.
  - patches/ubuntu/no-asm-mtune-i686.diff: Fixed in recent binutils.
* This upstream merge fixes a nasty hang in pulseaudio (LP: #1085342)
* Bump MIN_KERNEL_SUPPORTED to 2.6.32 on ARM, now that we no longer
  have to support shonky 2.6.31 kernels on imx51 babbage builders.
* Drop patches/ubuntu/local-disable-nscd-host-caching.diff, as these
  issues were apparently resolved upstream a while ago (LP: #613662)
* Fix the compiled-in bug URL to point to launchpad.net, not Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
This patch reverts the following commit, which causes problem with ruby.
2
 
 
3
 
        2011-05-13  Ulrich Drepper  <drepper@gmail.com>
4
 
 
5
 
                [BZ #12724]
6
 
                * libio/fileops.c (_IO_new_file_close_it): Always flush when
7
 
                currently writing and seek to current position when not.
8
 
                * libio/Makefile (tests): Add bug-fclose1.
9
 
                * libio/bug-fclose1.c: New file.
10
 
 
11
 
---
12
 
 libio/Makefile      |    2 
13
 
 libio/bug-fclose1.c |  132 ----------------------------------------------------
14
 
 libio/fileops.c     |   14 +----
15
 
 3 files changed, 4 insertions(+), 144 deletions(-)
16
 
 
17
 
--- a/libio/Makefile
18
 
+++ b/libio/Makefile
19
 
@@ -66,7 +66,7 @@
20
 
        tst-mmap2-eofsync tst-mmap-offend bug-fopena+           \
21
 
        bug-ungetc2 bug-ungetc3 bug-ungetc4                     \
22
 
        tst-memstream1 tst-memstream2                           \
23
 
-       bug-memstream1 tst-popen1 bug-fclose1
24
 
+       bug-memstream1 tst-popen1
25
 
 tests-$(OPTION_EGLIBC_LOCALE_CODE)                             \
26
 
      += tst-swscanf tst-fgetws tst-fopenloc tst-setvbuf1       \
27
 
        tst-ungetwc1 tst-ungetwc2 bug-ftell bug-ungetwc2        \
28
 
--- a/libio/bug-fclose1.c
29
 
+++ /dev/null
30
 
@@ -1,132 +0,0 @@
31
 
-// BZ #12724
32
 
-
33
 
-static void do_prepare (void);
34
 
-#define PREPARE(argc, argv) do_prepare ()
35
 
-static int do_test (void);
36
 
-#define TEST_FUNCTION do_test()
37
 
-#include "../test-skeleton.c"
38
 
-
39
 
-
40
 
-static int fd;
41
 
-
42
 
-
43
 
-static void
44
 
-do_prepare (void)
45
 
-{
46
 
-  fd = create_temp_file ("bug-fclose1.", NULL);
47
 
-  if (fd == -1)
48
 
-    {
49
 
-      printf ("cannot create temporary file: %m\n");
50
 
-      exit (1);
51
 
-    }
52
 
-}
53
 
-
54
 
-
55
 
-static int
56
 
-do_test (void)
57
 
-{
58
 
-  static const char pattern[] = "hello world";
59
 
-
60
 
-  /* Prepare a seekable file.  */
61
 
-  if (write (fd, pattern, sizeof pattern) != sizeof pattern)
62
 
-    {
63
 
-      printf ("cannot write pattern: %m\n");
64
 
-      return 1;
65
 
-    }
66
 
-  if (lseek (fd, 1, SEEK_SET) != 1)
67
 
-    {
68
 
-      printf ("cannot seek after write: %m\n");
69
 
-      return 1;
70
 
-    }
71
 
-
72
 
-  /* Create an output stream visiting the file; when it is closed, all
73
 
-     other file descriptors visiting the file must see the new file
74
 
-     position.  */
75
 
-  int fd2 = dup (fd);
76
 
-  if (fd2 < 0)
77
 
-    {
78
 
-      printf ("cannot duplicate descriptor for writing: %m\n");
79
 
-      return 1;
80
 
-    }
81
 
-  FILE *f = fdopen (fd2, "w");
82
 
-  if (f == NULL)
83
 
-    {
84
 
-      printf ("first fdopen failed: %m\n");
85
 
-      return 1;
86
 
-    }
87
 
-  if (fputc (pattern[1], f) != pattern[1])
88
 
-    {
89
 
-      printf ("fputc failed: %m\n");
90
 
-      return 1;
91
 
-    }
92
 
-  if (fclose (f) != 0)
93
 
-    {
94
 
-      printf ("first fclose failed: %m\n");
95
 
-      return 1;
96
 
-    }
97
 
-  errno = 0;
98
 
-  if (lseek (fd2, 0, SEEK_CUR) != -1)
99
 
-    {
100
 
-      printf ("lseek after fclose after write did not fail\n");
101
 
-      return 1;
102
 
-    }
103
 
-  if (errno != EBADF)
104
 
-    {
105
 
-      printf ("lseek after fclose after write did not fail with EBADF: %m\n");
106
 
-      return 1;
107
 
-    }
108
 
-  off_t o = lseek (fd, 0, SEEK_CUR);
109
 
-  if (o != 2)
110
 
-    {
111
 
-      printf ("\
112
 
-lseek on original descriptor after first fclose returned %ld, expected 2\n",
113
 
-             (long int) o);
114
 
-      return 1;
115
 
-    }
116
 
-
117
 
-  /* Likewise for an input stream.  */
118
 
-  fd2 = dup (fd);
119
 
-  if (fd2 < 0)
120
 
-     {
121
 
-      printf ("cannot duplicate descriptor for reading: %m\n");
122
 
-      return 1;
123
 
-    }
124
 
-  f = fdopen (fd2, "r");
125
 
-   if (f == NULL)
126
 
-    {
127
 
-      printf ("second fdopen failed: %m\n");
128
 
-      return 1;
129
 
-    }
130
 
-   char c = fgetc (f);
131
 
-   if (c != pattern[2])
132
 
-     {
133
 
-       printf ("getc returned %c, expected %c\n", c, pattern[2]);
134
 
-       return 1;
135
 
-     }
136
 
-  if (fclose (f) != 0)
137
 
-    {
138
 
-      printf ("second fclose failed: %m\n");
139
 
-      return 1;
140
 
-    }
141
 
-  errno = 0;
142
 
-  if (lseek (fd2, 0, SEEK_CUR) != -1)
143
 
-    {
144
 
-      printf ("lseek after fclose after read did not fail\n");
145
 
-      return 1;
146
 
-    }
147
 
-  if (errno != EBADF)
148
 
-    {
149
 
-      printf ("lseek after fclose after read did not fail with EBADF: %m\n");
150
 
-      return 1;
151
 
-    }
152
 
-  o = lseek (fd, 0, SEEK_CUR);
153
 
-  if (o != 3)
154
 
-    {
155
 
-      printf ("\
156
 
-lseek on original descriptor after second fclose returned %ld, expected 3\n",
157
 
-             (long int) o);
158
 
-      return 1;
159
 
-    }
160
 
-
161
 
-  return 0;
162
 
-}
163
 
--- a/libio/fileops.c
164
 
+++ b/libio/fileops.c
165
 
@@ -156,21 +156,13 @@
166
 
 _IO_new_file_close_it (fp)
167
 
      _IO_FILE *fp;
168
 
 {
169
 
+  int write_status;
170
 
   if (!_IO_file_is_open (fp))
171
 
     return EOF;
172
 
 
173
 
-  int write_status;
174
 
-  if (_IO_in_put_mode (fp))
175
 
+  if ((fp->_flags & _IO_NO_WRITES) == 0
176
 
+      && (fp->_flags & _IO_CURRENTLY_PUTTING) != 0)
177
 
     write_status = _IO_do_flush (fp);
178
 
-  else if (fp->_offset != _IO_pos_BAD && fp->_IO_read_base != NULL
179
 
-          && !_IO_in_backup (fp))
180
 
-    {
181
 
-      off64_t o = _IO_SEEKOFF (fp, 0, _IO_seek_cur, 0);
182
 
-      if (o == WEOF)
183
 
-       write_status = EOF;
184
 
-      else
185
 
-       write_status = _IO_SYSSEEK (fp, o, SEEK_SET) < 0 ? EOF : 0;
186
 
-    }
187
 
   else
188
 
     write_status = 0;
189