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

« back to all changes in this revision

Viewing changes to .pc/any/CVE-2015-8776.diff/time/tst-strftime.c

  • Committer: Package Import Robot
  • Author(s): Steve Beattie
  • Date: 2016-04-08 23:26:02 UTC
  • Revision ID: package-import@ubuntu.com-20160408232602-694337pzn1m5xgc3
Tags: 2.19-0ubuntu6.8
* SECURITY UPDATE: buffer overflow in gethostbyname_r and related
  functions
  - debian/patches/any/CVE-2015-1781.diff: take alignment padding
    into account when computing if buffer is too small.
  - CVE-2015-1781
* SECURITY UPDATE: glibc Name Service Switch (NSS) denial of sevice
  - debian/patches/any/CVE-2014-8121-1.diff: do not close NSS files
    database during iteration.
  - debian/patches/any/CVE-2014-8121-2.diff: Separate internal state
    between getXXent and getXXbyYY NSS calls.
  - CVE-2014-8121
* SECURITY UPDATE: glibc unbounded stack usage in NaN strtod
  conversion
  - debian/patches/any/CVE-2014-9761-1.diff: Refactor strtod parsing
    of NaN payloads.
  - debian/patches/any/CVE-2014-9761-1.diff:  Fix nan functions
    handling of payload strings
  - CVE-2014-9761
* SECURITY UPDATE: NSS files long line buffer overflow
  - debian/patches/any/CVE-2015-5277.diff: Don't ignore too long
    lines in nss_files
  - CVE-2015-5277
* SECURITY UPDATE: out of range data to strftime() causes segfault
  (denial of service)
  - debian/patches/any/CVE-2015-8776.diff: add range checks to
    strftime() processing
  - CVE-2015-8776
* SECURITY UPDATE: glibc honors LD_POINTER_GUARD env for setuid
  AT_SECURE programs (e.g. setuid), allowing disabling of pointer
  mangling
  - debian/patches/any/CVE-2015-8777.diff: Always enable pointer
    guard
  - CVE-2015-8777
* SECURITY UPDATE: integer overflow in hcreate and hcreate_r
  - debian/patches/any/CVE-2015-8778.diff: check for large inputs
  - CVE-2015-8778
* SECURITY UPDATE: unbounded stack allocation in catopen()
  - debian/patches/any/CVE-2015-8779.diff: stop using unbounded
    alloca()
  - CVE-2015-8779
* SECURITY UPDATE: Stack overflow in _nss_dns_getnetbyname_r
  - debian/patches/any/CVE-2016-3075.diff: do not make unneeded
    memory copy on the stack.
  - CVE-2016-3075
* SECURITY UPDATE: pt_chown privilege escalation
  - debian/patches/any/CVE-2016-2856.diff: grantpt: trust the kernel
    about pty group and permission mode
  - debian/sysdeps/linux.mk: don't build pt_chown
  - debian/rules.d/debhelper.mk: only install pt_chown when built.
  - CVE-2016-2856, CVE-2013-2207
* debian/debhelper.in/libc.postinst: add reboot notifications for
  security updates (LP: #1546457)
* debian/patches/ubuntu/submitted-no-stack-backtrace.diff: update
  patch to eliminate compiler warning.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
#include <string.h>
 
4
#include <time.h>
 
5
 
 
6
 
 
7
static struct
 
8
{
 
9
  const char *fmt;
 
10
  size_t min;
 
11
  size_t max;
 
12
} tests[] =
 
13
  {
 
14
    { "%2000Y", 2000, 4000 },
 
15
    { "%02000Y", 2000, 4000 },
 
16
    { "%_2000Y", 2000, 4000 },
 
17
    { "%-2000Y", 2000, 4000 },
 
18
  };
 
19
#define ntests (sizeof (tests) / sizeof (tests[0]))
 
20
 
 
21
 
 
22
static int
 
23
do_test (void)
 
24
{
 
25
  size_t cnt;
 
26
  int result = 0;
 
27
 
 
28
  time_t tnow = time (NULL);
 
29
  struct tm *now = localtime (&tnow);
 
30
 
 
31
  for (cnt = 0; cnt < ntests; ++cnt)
 
32
    {
 
33
      size_t size = 0;
 
34
      int res;
 
35
      char *buf = NULL;
 
36
 
 
37
      do
 
38
        {
 
39
          size += 500;
 
40
          buf = (char *) realloc (buf, size);
 
41
          if (buf == NULL)
 
42
            {
 
43
              puts ("out of memory");
 
44
              exit (1);
 
45
            }
 
46
 
 
47
          res = strftime (buf, size, tests[cnt].fmt, now);
 
48
          if (res != 0)
 
49
            break;
 
50
        }
 
51
      while (size < tests[cnt].max);
 
52
 
 
53
      if (res == 0)
 
54
        {
 
55
          printf ("%Zu: %s: res == 0 despite size == %Zu\n",
 
56
                  cnt, tests[cnt].fmt, size);
 
57
          result = 1;
 
58
        }
 
59
      else if (size < tests[cnt].min)
 
60
        {
 
61
          printf ("%Zu: %s: size == %Zu was enough\n",
 
62
                  cnt, tests[cnt].fmt, size);
 
63
          result = 1;
 
64
        }
 
65
      else
 
66
        printf ("%Zu: %s: size == %Zu: OK\n", cnt, tests[cnt].fmt, size);
 
67
 
 
68
      free (buf);
 
69
    }
 
70
 
 
71
  struct tm ttm =
 
72
    {
 
73
      /* Initialize the fields which are needed in the tests.  */
 
74
      .tm_mday = 1,
 
75
      .tm_hour = 2
 
76
    };
 
77
  const struct
 
78
  {
 
79
    const char *fmt;
 
80
    const char *exp;
 
81
    size_t n;
 
82
  } ftests[] =
 
83
    {
 
84
      { "%-e", "1", 1 },
 
85
      { "%-k", "2", 1 },
 
86
      { "%-l", "2", 1 },
 
87
    };
 
88
#define nftests (sizeof (ftests) / sizeof (ftests[0]))
 
89
  for (cnt = 0; cnt < nftests; ++cnt)
 
90
    {
 
91
      char buf[100];
 
92
      size_t r = strftime (buf, sizeof (buf), ftests[cnt].fmt, &ttm);
 
93
      if (r != ftests[cnt].n)
 
94
        {
 
95
          printf ("strftime(\"%s\") returned %zu not %zu\n",
 
96
                  ftests[cnt].fmt, r, ftests[cnt].n);
 
97
          result = 1;
 
98
        }
 
99
      if (strcmp (buf, ftests[cnt].exp) != 0)
 
100
        {
 
101
          printf ("strftime(\"%s\") produced \"%s\" not \"%s\"\n",
 
102
                  ftests[cnt].fmt, buf, ftests[cnt].exp);
 
103
          result = 1;
 
104
        }
 
105
    }
 
106
 
 
107
  return result;
 
108
}
 
109
 
 
110
#define TEST_FUNCTION do_test ()
 
111
#include "../test-skeleton.c"