~ubuntu-branches/debian/squeeze/ntp/squeeze-201010051545

« back to all changes in this revision

Viewing changes to parseutil/dcfd.c

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2009-01-05 21:10:03 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090105211003-mh6zc3um4k1uhsj7
Tags: 1:4.2.4p4+dfsg-8
It did not properly check the return value of EVP_VerifyFinal
which results in an malformed DSA signature being treated as
a good signature rather than as an error.  (CVE-2009-0021)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * /src/NTP/ntp-4/parseutil/dcfd.c,v 4.9 1999/02/28 13:06:27 kardel RELEASE_19990228_A
 
2
 * /src/NTP/REPOSITORY/ntp4-dev/parseutil/dcfd.c,v 4.18 2005/10/07 22:08:18 kardel RELEASE_20051008_A
3
3
 *  
4
 
 * dcfd.c,v 4.9 1999/02/28 13:06:27 kardel RELEASE_19990228_A
 
4
 * dcfd.c,v 4.18 2005/10/07 22:08:18 kardel RELEASE_20051008_A
5
5
 *
6
6
 * DCF77 100/200ms pulse synchronisation daemon program (via 50Baud serial line)
7
7
 *
13
13
 * Lacks:
14
14
 *  Leap second handling (at that level you should switch to NTP Version 4 - really!)
15
15
 *
16
 
 * Copyright (C) 1995-1999 by Frank Kardel <kardel@acm.org>
17
 
 * Copyright (C) 1993-1994 by Frank Kardel
18
 
 * Friedrich-Alexander Universit�t Erlangen-N�rnberg, Germany
19
 
 *                                    
20
 
 * This program is distributed in the hope that it will be useful,
21
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23
 
 *
24
 
 * This program may not be sold or used for profit without prior
25
 
 * written consent of the author.
 
16
 * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
 
17
 * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universit�t Erlangen-N�rnberg, Germany
 
18
 *
 
19
 * Redistribution and use in source and binary forms, with or without
 
20
 * modification, are permitted provided that the following conditions
 
21
 * are met:
 
22
 * 1. Redistributions of source code must retain the above copyright
 
23
 *    notice, this list of conditions and the following disclaimer.
 
24
 * 2. Redistributions in binary form must reproduce the above copyright
 
25
 *    notice, this list of conditions and the following disclaimer in the
 
26
 *    documentation and/or other materials provided with the distribution.
 
27
 * 3. Neither the name of the author nor the names of its contributors
 
28
 *    may be used to endorse or promote products derived from this software
 
29
 *    without specific prior written permission.
 
30
 *
 
31
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 
32
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
33
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
34
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 
35
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
36
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
37
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
38
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
39
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
40
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
41
 * SUCH DAMAGE.
 
42
 *
26
43
 */
27
44
 
28
45
#ifdef HAVE_CONFIG_H
29
46
# include <config.h>
30
47
#endif
31
48
 
 
49
#include <sys/ioctl.h>
32
50
#include <unistd.h>
33
51
#include <stdio.h>
34
52
#include <fcntl.h>
112
130
     extern int errno;
113
131
#endif
114
132
 
 
133
static char *revision = "4.18";
 
134
 
115
135
/*
116
136
 * display received data (avoids also detaching from tty)
117
137
 */
1549
1569
                memset(term.c_cc, 0, sizeof(term.c_cc));
1550
1570
                term.c_cc[VMIN] = 1;
1551
1571
#ifdef NO_PARENB_IGNPAR
1552
 
                term.c_cflag = B50|CS8|CREAD|CLOCAL;
 
1572
                term.c_cflag = CS8|CREAD|CLOCAL;
1553
1573
#else
1554
 
                term.c_cflag = B50|CS8|CREAD|CLOCAL|PARENB;
 
1574
                term.c_cflag = CS8|CREAD|CLOCAL|PARENB;
1555
1575
#endif
1556
1576
                term.c_iflag = IGNPAR;
1557
1577
                term.c_oflag = 0;
1558
1578
                term.c_lflag = 0;
1559
1579
 
 
1580
                cfsetispeed(&term, B50);
 
1581
                cfsetospeed(&term, B50);
 
1582
 
1560
1583
                if (TTY_SETATTR(fd, &term) == -1)
1561
1584
                {
1562
1585
                        perror("tcsetattr");
1581
1604
                /*
1582
1605
                 * setup periodic operations (state control / frequency control)
1583
1606
                 */
1584
 
#ifdef HAVE_SIGVEC
1585
 
                {
1586
 
                        struct sigvec vec;
1587
 
 
1588
 
                        vec.sv_handler   = tick;
1589
 
                        vec.sv_mask      = 0;
1590
 
                        vec.sv_flags     = 0;
1591
 
 
1592
 
                        if (sigvec(SIGALRM, &vec, (struct sigvec *)0) == -1)
1593
 
                        {
1594
 
                                syslog(LOG_ERR, "sigvec(SIGALRM): %m");
1595
 
                                exit(1);
1596
 
                        }
1597
 
                }
1598
 
#else
1599
1607
#ifdef HAVE_SIGACTION
1600
1608
                {
1601
1609
                        struct sigaction act;
1602
1610
 
1603
 
                        act.sa_handler   = tick;
1604
1611
# ifdef HAVE_SA_SIGACTION_IN_STRUCT_SIGACTION
1605
1612
                        act.sa_sigaction = (void (*) P((int, siginfo_t *, void *)))0;
1606
1613
# endif /* HAVE_SA_SIGACTION_IN_STRUCT_SIGACTION */
 
1614
                        act.sa_handler   = tick;
1607
1615
                        sigemptyset(&act.sa_mask);
1608
1616
                        act.sa_flags     = 0;
1609
1617
 
1614
1622
                        }
1615
1623
                }
1616
1624
#else
 
1625
#ifdef HAVE_SIGVEC
 
1626
                {
 
1627
                        struct sigvec vec;
 
1628
 
 
1629
                        vec.sv_handler   = tick;
 
1630
                        vec.sv_mask      = 0;
 
1631
                        vec.sv_flags     = 0;
 
1632
 
 
1633
                        if (sigvec(SIGALRM, &vec, (struct sigvec *)0) == -1)
 
1634
                        {
 
1635
                                syslog(LOG_ERR, "sigvec(SIGALRM): %m");
 
1636
                                exit(1);
 
1637
                        }
 
1638
                }
 
1639
#else
1617
1640
                (void) signal(SIGALRM, tick);
1618
1641
#endif
1619
1642
#endif
1637
1660
                (void) alarm(1<<ADJINTERVAL);
1638
1661
#endif
1639
1662
 
1640
 
                PRINTF("  DCF77 monitor - Copyright (C) 1993-1998 by Frank Kardel\n\n");
 
1663
                PRINTF("  DCF77 monitor %s - Copyright (C) 1993-2005 by Frank Kardel\n\n", revision);
1641
1664
 
1642
1665
                pbuf[60] = '\0';
1643
1666
                for ( i = 0; i < 60; i++)
1850
1873
  
1851
1874
        return 0;
1852
1875
}
 
1876
 
 
1877
/*
 
1878
 * History:
 
1879
 *
 
1880
 * dcfd.c,v
 
1881
 * Revision 4.18  2005/10/07 22:08:18  kardel
 
1882
 * make dcfd.c compile on NetBSD 3.99.9 again (configure/sigvec compatibility fix)
 
1883
 *
 
1884
 * Revision 4.17.2.1  2005/10/03 19:15:16  kardel
 
1885
 * work around configure not detecting a missing sigvec compatibility
 
1886
 * interface on NetBSD 3.99.9 and above
 
1887
 *
 
1888
 * Revision 4.17  2005/08/10 10:09:44  kardel
 
1889
 * output revision information
 
1890
 *
 
1891
 * Revision 4.16  2005/08/10 06:33:25  kardel
 
1892
 * cleanup warnings
 
1893
 *
 
1894
 * Revision 4.15  2005/08/10 06:28:45  kardel
 
1895
 * fix setting of baud rate
 
1896
 *
 
1897
 * Revision 4.14  2005/04/16 17:32:10  kardel
 
1898
 * update copyright
 
1899
 *
 
1900
 * Revision 4.13  2004/11/14 15:29:41  kardel
 
1901
 * support PPSAPI, upgrade Copyright to Berkeley style
 
1902
 *
 
1903
 */