]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Wed, 24 Jul 2002 10:44:53 +0000 (10:44 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 24 Jul 2002 10:44:53 +0000 (10:44 +0000)
2002-07-24  Ulrich Drepper  <drepper@redhat.com>

* locale/hashval.h: Make more self-containedby defining LONG_BITS.
* locale/programs/simple-hash.c: Remove LONG_BITS definition.

* locale/programs/locarchive.c (add_locale_to_archive): Correct
test to detect duplicate locales.

* libio/fileops.c (_IO_new_file_seekoff): Fail if relative
position would be before beginning of file.
(_IO_file_seekoff_mmap): Likewise.
* libio/Makefile (tests): Add bug-fseek.
* libio/bug-fseek.c: New file.

* intl/explodename.c: Remove support for CEN-style locale variables.
It was never used and shouldn't be since it's not portable.
* intl/finddomain.c: Likewise.
* intl/l10nflist.c: Likewise.
* intl/loadinfo.h: Likewise.
* locale/findlocale.c: Likewise.

ChangeLog
libio/Makefile
libio/bug-fseek.c [new file with mode: 0644]
libio/fileops.c
locale/hashval.h
locale/programs/locarchive.c
locale/programs/simple-hash.c

index 8c648502d1c995c134836f952457163ab4790e53..bfa4550724a80bfb9c160762e41ed670df6fadf5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2002-07-24  Ulrich Drepper  <drepper@redhat.com>
+
+       * locale/hashval.h: Make more self-containedby defining LONG_BITS.
+       * locale/programs/simple-hash.c: Remove LONG_BITS definition.
+
+       * locale/programs/locarchive.c (add_locale_to_archive): Correct
+       test to detect duplicate locales.
+
+       * libio/fileops.c (_IO_new_file_seekoff): Fail if relative
+       position would be before beginning of file.
+       (_IO_file_seekoff_mmap): Likewise.
+       * libio/Makefile (tests): Add bug-fseek.
+       * libio/bug-fseek.c: New file.
+
+       * intl/explodename.c: Remove support for CEN-style locale variables.
+       It was never used and shouldn't be since it's not portable.
+       * intl/finddomain.c: Likewise.
+       * intl/l10nflist.c: Likewise.
+       * intl/loadinfo.h: Likewise.
+       * locale/findlocale.c: Likewise.
+
 2002-07-24  Roland McGrath  <roland@frob.com>
 
        * libio/fileops.c (_IO_file_seekoff_mmap): When just examining the
index d10d6c1648256d8fafc563dd323a4387872a5acd..132634608fba744a5e178c1de4f23d28080b6c8c 100644 (file)
@@ -50,7 +50,7 @@ tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc   \
        tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-fopenloc          \
        tst-fgetws tst-ungetwc1 tst-ungetwc2 tst-swscanf tst-sscanf           \
        tst-mmap-setvbuf bug-ungetwc1 bug-ungetwc2 tst-atime tst-eof          \
-       tst-freopen bug-rewind bug-ungetc
+       tst-freopen bug-rewind bug-ungetc bug-fseek
 test-srcs = test-freopen
 
 all: # Make this the default target; it will be defined in Rules.
diff --git a/libio/bug-fseek.c b/libio/bug-fseek.c
new file mode 100644 (file)
index 0000000..d8cd712
--- /dev/null
@@ -0,0 +1,94 @@
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static char *fname;
+
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+
+static void
+do_prepare (void)
+{
+  static const char pattern[] = "12345678901234567890";
+  int fd = create_temp_file ("bug-fseek.", &fname);
+  if (fd == -1)
+    {
+      printf ("cannot create temporary file: %m\n");
+      exit (1);
+    }
+
+  if (write (fd, pattern, sizeof (pattern)) != sizeof (pattern))
+    {
+      perror ("short write");
+      abort ();
+    }
+  close (fd);
+}
+
+
+
+static int
+do_test (void)
+{
+  FILE *f;
+  int result = 0;
+  char buf[10];
+
+
+  if ((f = fopen (fname, "r")) == (FILE *) NULL)
+    {
+      perror ("fopen(\"r\")");
+    }
+
+  fread (buf, 3, 1, f);
+  errno = 0;
+  if (fseek (f, -10, SEEK_CUR) == 0)
+    {
+      printf ("fseek() for r to before start of file worked!\n");
+      result = 1;
+    }
+  else if (errno != EINVAL)
+    {
+      printf ("\
+fseek() for r to before start of file did not set errno to EINVAL.  \
+Got %d instead\n",
+        errno);
+      result = 1;
+    }
+
+  fclose (f);
+
+
+  if ((f = fopen (fname, "r+")) == (FILE *) NULL)
+    {
+      perror ("fopen(\"r+\")");
+    }
+
+  fread (buf, 3, 1, f);
+  errno = 0;
+  if (fseek (f, -10, SEEK_CUR) == 0)
+    {
+      printf ("fseek() for r+ to before start of file worked!\n");
+      result = 1;
+    }
+  else if (errno != EINVAL)
+    {
+      printf ("\
+fseek() for r+ to before start of file did not set errno to EINVAL.  \
+Got %d instead\n",
+        errno);
+      result = 1;
+    }
+
+  fclose (f);
+
+  return result;
+}
index fa4c8e0fa812092e131d076a68b1313d2d4fc559..1794dce57f37078ca2cff427ad226b0d0ab4a104 100644 (file)
@@ -778,6 +778,11 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
        goto dumb;
       /* Make offset absolute, assuming current pointer is file_ptr(). */
       offset += fp->_offset;
+      if (offset < 0)
+       {
+         __set_errno (EINVAL);
+         return EOF;
+       }
 
       dir = _IO_seek_set;
       break;
@@ -934,6 +939,11 @@ _IO_file_seekoff_mmap (fp, offset, dir, mode)
     case _IO_seek_cur:
       /* Adjust for read-ahead (bytes is buffer). */
       offset += fp->_IO_read_ptr - fp->_IO_read_base;
+      if (offset < 0)
+       {
+         __set_errno (EINVAL);
+         return EOF;
+       }
       break;
     case _IO_seek_set:
       break;
index 15ec1244cf74ad546c17b953d0a9172c6f9c3302..e35957dde3ab385910657caf1736f1755b4d4acc 100644 (file)
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-unsigned long
+#ifndef        LONGBITS
+# define LONGBITS (sizeof (long int) * BITSPERBYTE)
+#endif
+
+unsigned long int compute_hashval (const void *key, size_t keylen);
+
+unsigned long int
 compute_hashval (key, keylen)
      const void *key;
      size_t keylen;
@@ -37,5 +43,5 @@ compute_hashval (key, keylen)
       hval = (hval << 9) | (hval >> (LONGBITS - 9));
       hval += (unsigned long int) *(((char *) key) + cnt++);
     }
-  return hval != 0 ? hval : ~((unsigned long) 0);
+  return hval != 0 ? hval : ~((unsigned long int) 0);
 }
index 9ef373a2e5694d3946c602579fd5b3db5c837c2c..de026b2a74d6bbf2a3118d400bb1e919efaf1faa 100644 (file)
@@ -531,7 +531,7 @@ add_locale_to_archive (ah, name, data, replace)
                     (char *) ah->addr + namehashtab[idx].name_offset) == 0)
        {
          /* Found the entry.  */
-         if (! replace)
+         if (namehashtab[idx].locrec_offset != 0 && ! replace)
            {
              if (! be_quiet)
                error (0, 0, _("locale '%s' already exists"), name);
index b52b5593d01d28a0707ea47a61ae71f343d8e16b..c319068677d6f69a3583913e249a2f3afe1de49e 100644 (file)
 # define BITSPERBYTE 8
 #endif
 
-#ifndef        LONGBITS
-# define LONGBITS (sizeof (long) * BITSPERBYTE)
-#endif
-
 #ifndef bcopy
 # define bcopy(s, d, n)        memcpy ((d), (s), (n))
 #endif