[pptp] Attack compiler and rpmlint warnings
Paul Howarth
pghmcfc at fedoraproject.org
Wed Jan 4 14:18:44 UTC 2012
commit a322d1799bc530487807e883ddd4bd558c328bca
Author: Paul Howarth <paul at city-fan.org>
Date: Mon Dec 12 14:08:43 2011 +0000
Attack compiler and rpmlint warnings
- Add patch to fix highly-parallel build (e.g. -j16)
- Add additional compiler warning flags to highlight questionable code
- Add patch to fix comparisons between signed and unsigned integers
- Add patch to fix const usage
- Add patch to fix missing field initializers
- Add patch to suppress warnings about possibly unused variables
- Add patch to fix declarations that are not prototypes
- Add patch to fix warnings about nested externs
- Add patch to fix dubious typecasts that violate strict-aliasing rules
- Update the FSF address references and GPLv2 license text
- Use default optimization level (-O2) again
Some of these patches have already been accepted upstream, with the
rest having been submitted for review.
pptp-1.7.2-aliasing.patch | 172 ++++++++++++++++++++++++++++++
pptp-1.7.2-const.patch | 52 +++++++++
pptp-1.7.2-field-init.patch | 11 ++
pptp-1.7.2-fsf-update.patch | 182 ++++++++++++++++++++++++++++++++
pptp-1.7.2-nested-externs.patch | 23 ++++
pptp-1.7.2-prototype.patch | 219 +++++++++++++++++++++++++++++++++++++++
pptp-1.7.2-sign-compare.patch | 150 ++++++++++++++++++++++++++
pptp-1.7.2-unused.patch | 73 +++++++++++++
pptp.spec | 51 +++++++++-
9 files changed, 930 insertions(+), 3 deletions(-)
---
diff --git a/pptp-1.7.2-aliasing.patch b/pptp-1.7.2-aliasing.patch
new file mode 100644
index 0000000..af901dd
--- /dev/null
+++ b/pptp-1.7.2-aliasing.patch
@@ -0,0 +1,172 @@
+diff -up pptp-1.7.2/pptp.c.alias pptp-1.7.2/pptp.c
+--- pptp-1.7.2/pptp.c.alias 2011-12-06 22:24:06.617318769 +0000
++++ pptp-1.7.2/pptp.c 2011-12-06 22:36:25.761692858 +0000
+@@ -463,7 +463,10 @@ int open_callmgr(struct in_addr inetaddr
+ char **envp, int pty_fd, int gre_fd)
+ {
+ /* Try to open unix domain socket to call manager. */
+- struct sockaddr_un where;
++ union {
++ struct sockaddr a;
++ struct sockaddr_un u;
++ } where;
+ const int NUM_TRIES = 3;
+ int i, fd;
+ pid_t pid;
+@@ -473,12 +476,12 @@ int open_callmgr(struct in_addr inetaddr
+ fatal("Could not create unix domain socket: %s", strerror(errno));
+ }
+ /* Make address */
+- callmgr_name_unixsock(&where, inetaddr, localbind);
++ callmgr_name_unixsock(&where.u, inetaddr, localbind);
+ for (i = 0; i < NUM_TRIES; i++) {
+- if (connect(fd, (struct sockaddr *) &where, sizeof(where)) < 0) {
++ if (connect(fd, &where.a, sizeof(where.u)) < 0) {
+ /* couldn't connect. We'll have to launch this guy. */
+
+- unlink (where.sun_path);
++ unlink (where.u.sun_path);
+
+ /* fork and launch call manager process */
+ switch (pid = fork()) {
+diff -up pptp-1.7.2/pptp_callmgr.c.alias pptp-1.7.2/pptp_callmgr.c
+--- pptp-1.7.2/pptp_callmgr.c.alias 2011-12-06 22:24:06.617318769 +0000
++++ pptp-1.7.2/pptp_callmgr.c 2011-12-06 22:34:46.142647941 +0000
+@@ -196,14 +196,17 @@ int callmgr_main(int argc, char **argv,
+ /* Step 5b: Handle new connection to UNIX socket */
+ if (FD_ISSET(unix_sock, &read_set)) {
+ /* New call! */
+- struct sockaddr_un from;
+- socklen_t len = sizeof(from);
++ union {
++ struct sockaddr a;
++ struct sockaddr_un u;
++ } from;
++ socklen_t len = sizeof(from.u);
+ PPTP_CALL * call;
+ struct local_callinfo *lci;
+ int s;
+ /* Accept the socket */
+ FD_CLR (unix_sock, &read_set);
+- if ((s = accept(unix_sock, (struct sockaddr *) &from, &len)) < 0) {
++ if ((s = accept(unix_sock, &from.a, &len)) < 0) {
+ warn("Socket not accepted: %s", strerror(errno));
+ goto skip_accept;
+ }
+@@ -313,11 +316,14 @@ cleanup:
+ /*** open_inetsock ************************************************************/
+ int open_inetsock(struct in_addr inetaddr)
+ {
+- struct sockaddr_in dest, src;
++ union {
++ struct sockaddr a;
++ struct sockaddr_in i;
++ } dest, src;
+ int s;
+- dest.sin_family = AF_INET;
+- dest.sin_port = htons(PPTP_PORT);
+- dest.sin_addr = inetaddr;
++ dest.i.sin_family = AF_INET;
++ dest.i.sin_port = htons(PPTP_PORT);
++ dest.i.sin_addr = inetaddr;
+ if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+ warn("socket: %s", strerror(errno));
+ return s;
+@@ -332,14 +338,14 @@ int open_inetsock(struct in_addr inetadd
+ #endif
+ if (localbind.s_addr != INADDR_NONE) {
+ bzero(&src, sizeof(src));
+- src.sin_family = AF_INET;
+- src.sin_addr = localbind;
+- if (bind(s, (struct sockaddr *) &src, sizeof(src)) != 0) {
++ src.i.sin_family = AF_INET;
++ src.i.sin_addr = localbind;
++ if (bind(s, &src.a, sizeof(src.i)) != 0) {
+ warn("bind: %s", strerror(errno));
+ close(s); return -1;
+ }
+ }
+- if (connect(s, (struct sockaddr *) &dest, sizeof(dest)) < 0) {
++ if (connect(s, &dest.a, sizeof(dest.i)) < 0) {
+ warn("connect: %s", strerror(errno));
+ close(s); return -1;
+ }
+@@ -349,7 +355,10 @@ int open_inetsock(struct in_addr inetadd
+ /*** open_unixsock ************************************************************/
+ int open_unixsock(struct in_addr inetaddr)
+ {
+- struct sockaddr_un where;
++ union {
++ struct sockaddr a;
++ struct sockaddr_un u;
++ } where;
+ struct stat st;
+ char *dir;
+ int s;
+@@ -357,21 +366,21 @@ int open_unixsock(struct in_addr inetadd
+ warn("socket: %s", strerror(errno));
+ return s;
+ }
+- callmgr_name_unixsock( &where, inetaddr, localbind);
+- if (stat(where.sun_path, &st) >= 0) {
++ callmgr_name_unixsock( &where.u, inetaddr, localbind);
++ if (stat(where.u.sun_path, &st) >= 0) {
+ warn("Call manager for %s is already running.", inet_ntoa(inetaddr));
+ close(s); return -1;
+ }
+ /* Make sure path is valid. */
+- dir = dirname(where.sun_path);
++ dir = dirname(where.u.sun_path);
+ if (!make_valid_path(dir, 0770))
+- fatal("Could not make path to %s: %s", where.sun_path, strerror(errno));
++ fatal("Could not make path to %s: %s", where.u.sun_path, strerror(errno));
+ free(dir);
+- if (bind(s, (struct sockaddr *) &where, sizeof(where)) < 0) {
++ if (bind(s, &where.a, sizeof(where.u)) < 0) {
+ warn("bind: %s", strerror(errno));
+ close(s); return -1;
+ }
+- chmod(where.sun_path, 0777);
++ chmod(where.u.sun_path, 0777);
+ listen(s, 127);
+ return s;
+ }
+diff -up pptp-1.7.2/pptp_gre.c.alias pptp-1.7.2/pptp_gre.c
+--- pptp-1.7.2/pptp_gre.c.alias 2011-12-06 22:24:06.627318773 +0000
++++ pptp-1.7.2/pptp_gre.c 2011-12-06 22:24:06.629318775 +0000
+@@ -85,7 +85,10 @@ uint64_t time_now_usecs(void)
+ /*** Open IP protocol socket **************************************************/
+ int pptp_gre_bind(struct in_addr inetaddr)
+ {
+- struct sockaddr_in src_addr, loc_addr;
++ union {
++ struct sockaddr a;
++ struct sockaddr_in i;
++ } loc_addr, src_addr;
+ int s = socket(AF_INET, SOCK_RAW, PPTP_PROTO);
+ if (s < 0) { warn("socket: %s", strerror(errno)); return -1; }
+ #ifdef SO_MARK
+@@ -98,16 +101,16 @@ int pptp_gre_bind(struct in_addr inetadd
+ #endif
+ if (localbind.s_addr != INADDR_NONE) {
+ bzero(&loc_addr, sizeof(loc_addr));
+- loc_addr.sin_family = AF_INET;
+- loc_addr.sin_addr = localbind;
+- if (bind(s, (struct sockaddr *) &loc_addr, sizeof(loc_addr)) != 0) {
++ loc_addr.i.sin_family = AF_INET;
++ loc_addr.i.sin_addr = localbind;
++ if (bind(s, &loc_addr.a, sizeof(loc_addr.i)) != 0) {
+ warn("bind: %s", strerror(errno)); close(s); return -1;
+ }
+ }
+- src_addr.sin_family = AF_INET;
+- src_addr.sin_addr = inetaddr;
+- src_addr.sin_port = 0;
+- if (connect(s, (struct sockaddr *) &src_addr, sizeof(src_addr)) < 0) {
++ src_addr.i.sin_family = AF_INET;
++ src_addr.i.sin_addr = inetaddr;
++ src_addr.i.sin_port = 0;
++ if (connect(s, &src_addr.a, sizeof(src_addr.i)) < 0) {
+ warn("connect: %s", strerror(errno)); close(s); return -1;
+ }
+ my = test_redirections();
diff --git a/pptp-1.7.2-const.patch b/pptp-1.7.2-const.patch
new file mode 100644
index 0000000..7cea0b2
--- /dev/null
+++ b/pptp-1.7.2-const.patch
@@ -0,0 +1,52 @@
+diff -up pptp-1.7.2/pptp.c.const pptp-1.7.2/pptp.c
+--- pptp-1.7.2/pptp.c.const 2011-11-30 18:58:39.713148113 +0000
++++ pptp-1.7.2/pptp.c 2011-12-01 09:23:29.716446618 +0000
+@@ -565,10 +565,13 @@ int get_call_id(int sock, pid_t gre, pid
+ void launch_pppd(char *ttydev, int argc, char **argv)
+ {
+ char *new_argv[argc + 4];/* XXX if not using GCC, hard code a limit here. */
++ char str_pppd[] = PPPD_BINARY;
++ char str_direct[] = "-direct";
++ char str_38400[] = "38400";
+ int i = 0, j;
+- new_argv[i++] = PPPD_BINARY;
++ new_argv[i++] = str_pppd;
+ #ifdef USER_PPP
+- new_argv[i++] = "-direct";
++ new_argv[i++] = str_direct;
+ /* ppp expects to have stdin connected to ttydev */
+ if ((j = open(ttydev, O_RDWR)) == -1)
+ fatal("Cannot open %s: %s", ttydev, strerror(errno));
+@@ -577,7 +580,7 @@ void launch_pppd(char *ttydev, int argc,
+ close(j);
+ #else
+ new_argv[i++] = ttydev;
+- new_argv[i++] = "38400";
++ new_argv[i++] = str_38400;
+ #endif
+ for (j = 0; j < argc; j++)
+ new_argv[i++] = argv[j];
+diff -up pptp-1.7.2/util.c.const pptp-1.7.2/util.c
+--- pptp-1.7.2/util.c.const 2008-05-14 07:33:55.000000000 +0100
++++ pptp-1.7.2/util.c 2011-11-30 18:58:39.719148114 +0000
+@@ -16,7 +16,7 @@
+ #endif
+
+ /* implementation of log_string, defined as extern in util.h */
+-char *log_string = "anon";
++const char *log_string = "anon";
+
+ static void open_log(void) __attribute__ ((constructor));
+ static void close_log(void) __attribute__ ((destructor));
+diff -up pptp-1.7.2/util.h.const pptp-1.7.2/util.h
+--- pptp-1.7.2/util.h.const 2008-05-14 07:33:55.000000000 +0100
++++ pptp-1.7.2/util.h 2011-11-30 18:59:47.458171318 +0000
+@@ -10,7 +10,7 @@
+ /* log_string is an identifier for this pptp process, passed from
+ command line using --log-string=X, and included with every log message.
+ Useful for people with multiple pptp sessions open at a time */
+-extern char * log_string;
++extern const char * log_string;
+
+ /* log_level sets the logging verbosity. Values range from 0 (errors only)
+ to 1 (errors and warnings) to 2 (high verbosity, for debugging) */
diff --git a/pptp-1.7.2-field-init.patch b/pptp-1.7.2-field-init.patch
new file mode 100644
index 0000000..8164965
--- /dev/null
+++ b/pptp-1.7.2-field-init.patch
@@ -0,0 +1,11 @@
+--- pptp-1.7.2/orckit_quirks.c.field 2008-05-14 07:33:55.000000000 +0100
++++ pptp-1.7.2/orckit_quirks.c 2011-12-01 09:31:04.762035792 +0000
+@@ -62,7 +62,7 @@ int
+ orckit_atur3_start_ctrl_conn_hook(struct pptp_start_ctrl_conn* packet)
+ {
+ struct pptp_start_ctrl_conn fixed_packet = {
+- {0}, /* we'll set the header later */
++ {0, 0, 0, 0 , 0}, /* we'll set the header later */
+ hton16(PPTP_VERSION), 0, 0,
+ hton32(PPTP_FRAME_ASYNC), hton32(PPTP_BEARER_ANALOG),
+ hton16(0) /* max channels */,
diff --git a/pptp-1.7.2-fsf-update.patch b/pptp-1.7.2-fsf-update.patch
new file mode 100644
index 0000000..8a2229f
--- /dev/null
+++ b/pptp-1.7.2-fsf-update.patch
@@ -0,0 +1,182 @@
+Index: COPYING
+===================================================================
+RCS file: /cvsroot/pptpclient/pptp-linux/COPYING,v
+retrieving revision 1.1.1.1
+diff -u -r1.1.1.1 COPYING
+--- COPYING 23 Dec 2000 08:19:51 -0000 1.1.1.1
++++ COPYING 8 Nov 2011 16:01:32 -0000
+@@ -1,12 +1,12 @@
+- GNU GENERAL PUBLIC LICENSE
+- Version 2, June 1991
++ GNU GENERAL PUBLIC LICENSE
++ Version 2, June 1991
+
+- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+- 675 Mass Ave, Cambridge, MA 02139, USA
++ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+- Preamble
++ Preamble
+
+ The licenses for most software are designed to take away your
+ freedom to share and change it. By contrast, the GNU General Public
+@@ -15,7 +15,7 @@
+ General Public License applies to most of the Free Software
+ Foundation's software and to any other program whose authors commit to
+ using it. (Some other Free Software Foundation software is covered by
+-the GNU Library General Public License instead.) You can apply it to
++the GNU Lesser General Public License instead.) You can apply it to
+ your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+@@ -55,8 +55,8 @@
+
+ The precise terms and conditions for copying, distribution and
+ modification follow.
+-
+- GNU GENERAL PUBLIC LICENSE
++
++ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+@@ -110,7 +110,7 @@
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+-
++
+ These requirements apply to the modified work as a whole. If
+ identifiable sections of that work are not derived from the Program,
+ and can be reasonably considered independent and separate works in
+@@ -168,7 +168,7 @@
+ access to copy the source code from the same place counts as
+ distribution of the source code, even though third parties are not
+ compelled to copy the source along with the object code.
+-
++
+ 4. You may not copy, modify, sublicense, or distribute the Program
+ except as expressly provided under this License. Any attempt
+ otherwise to copy, modify, sublicense or distribute the Program is
+@@ -225,7 +225,7 @@
+
+ This section is intended to make thoroughly clear what is believed to
+ be a consequence of the rest of this License.
+-
++
+ 8. If the distribution and/or use of the Program is restricted in
+ certain countries either by patents or by copyrighted interfaces, the
+ original copyright holder who places the Program under this License
+@@ -255,7 +255,7 @@
+ of preserving the free status of all derivatives of our free software and
+ of promoting the sharing and reuse of software generally.
+
+- NO WARRANTY
++ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+@@ -277,9 +277,9 @@
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGES.
+
+- END OF TERMS AND CONDITIONS
+-
+- Appendix: How to Apply These Terms to Your New Programs
++ END OF TERMS AND CONDITIONS
++
++ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+ possible use to the public, the best way to achieve this is to make it
+@@ -291,7 +291,7 @@
+ the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+- Copyright (C) 19yy <name of author>
++ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+@@ -303,16 +303,16 @@
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+- You should have received a copy of the GNU General Public License
+- along with this program; if not, write to the Free Software
+- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ You should have received a copy of the GNU General Public License along
++ with this program; if not, write to the Free Software Foundation, Inc.,
++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Also add information on how to contact you by electronic and paper mail.
+
+ If the program is interactive, make it output a short notice like this
+ when it starts in an interactive mode:
+
+- Gnomovision version 69, Copyright (C) 19yy name of author
++ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+@@ -335,5 +335,5 @@
+ This General Public License does not permit incorporating your program into
+ proprietary programs. If your program is a subroutine library, you may
+ consider it more useful to permit linking proprietary applications with the
+-library. If this is what you want to do, use the GNU Library General
++library. If this is what you want to do, use the GNU Lesser General
+ Public License instead of this License.
+Index: README
+===================================================================
+RCS file: /cvsroot/pptpclient/pptp-linux/README,v
+retrieving revision 1.5
+diff -u -r1.5 README
+--- README 28 Aug 2007 00:17:13 -0000 1.5
++++ README 8 Nov 2011 16:01:32 -0000
+@@ -17,7 +17,8 @@
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
++ 02110-1301, USA.
+
+ You can find notes on installing in the file INSTALL, usage notes in
+ the file USING, design notes in the Documentation directory, and the
+Index: pptp.c
+===================================================================
+RCS file: /cvsroot/pptpclient/pptp-linux/pptp.c,v
+retrieving revision 1.55
+diff -u -r1.55 pptp.c
+--- pptp.c 3 Mar 2011 22:44:57 -0000 1.55
++++ pptp.c 8 Nov 2011 16:01:33 -0000
+@@ -14,7 +14,8 @@
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
++ 02110-1301, USA.
+
+ pptp.c ... client shell to launch call managers, data handlers, and
+ the pppd from the command line.
+Index: routing.c
+===================================================================
+RCS file: /cvsroot/pptpclient/pptp-linux/routing.c,v
+retrieving revision 1.5
+diff -u -r1.5 routing.c
+--- routing.c 3 Mar 2011 22:44:57 -0000 1.5
++++ routing.c 8 Nov 2011 16:01:33 -0000
+@@ -14,7 +14,8 @@
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
++ 02110-1301, USA
+
+ */
+
diff --git a/pptp-1.7.2-nested-externs.patch b/pptp-1.7.2-nested-externs.patch
new file mode 100644
index 0000000..a3751a9
--- /dev/null
+++ b/pptp-1.7.2-nested-externs.patch
@@ -0,0 +1,23 @@
+diff -up pptp-1.7.2/pptp_gre.c.nested pptp-1.7.2/pptp_gre.c
+--- pptp-1.7.2/pptp_gre.c.nested 2011-12-06 16:45:34.605691678 +0000
++++ pptp-1.7.2/pptp_gre.c 2011-12-06 19:07:14.169449813 +0000
+@@ -23,6 +23,10 @@
+ #include "pqueue.h"
+ #include "test.h"
+
++/* globals from pptp.c */
++extern struct in_addr localbind;
++extern int rtmark;
++
+ #define PACKET_MAX 8196
+ /* test for a 32 bit counter overflow */
+ #define WRAPPED( curseq, lastseq) \
+@@ -82,8 +86,6 @@ uint64_t time_now_usecs(void)
+ int pptp_gre_bind(struct in_addr inetaddr)
+ {
+ struct sockaddr_in src_addr, loc_addr;
+- extern struct in_addr localbind;
+- extern int rtmark;
+ int s = socket(AF_INET, SOCK_RAW, PPTP_PROTO);
+ if (s < 0) { warn("socket: %s", strerror(errno)); return -1; }
+ #ifdef SO_MARK
diff --git a/pptp-1.7.2-prototype.patch b/pptp-1.7.2-prototype.patch
new file mode 100644
index 0000000..34a0ac8
--- /dev/null
+++ b/pptp-1.7.2-prototype.patch
@@ -0,0 +1,219 @@
+diff -up pptp-1.7.2/pptp_ctrl.c.prototype pptp-1.7.2/pptp_ctrl.c
+--- pptp-1.7.2/pptp_ctrl.c.prototype 2011-12-06 16:41:47.391574067 +0000
++++ pptp-1.7.2/pptp_ctrl.c 2011-12-06 16:41:47.405574074 +0000
+@@ -174,7 +174,7 @@ int max_echo_wait = PPTP_TIMEOUT;
+
+ /* Local prototypes */
+ static void pptp_reset_timer(void);
+-static void pptp_handle_timer();
++static void pptp_handle_timer(void);
+ /* Write/read as much as we can without blocking. */
+ int pptp_write_some(PPTP_CONN * conn);
+ int pptp_read_some(PPTP_CONN * conn);
+@@ -1059,7 +1059,7 @@ static void pptp_reset_timer(void)
+
+
+ /*** Handle keep-alive timer **************************************************/
+-static void pptp_handle_timer()
++static void pptp_handle_timer(void)
+ {
+ int i;
+ /* "Keep Alives and Timers, 1": check connection state */
+diff -up pptp-1.7.2/pptp_gre.c.prototype pptp-1.7.2/pptp_gre.c
+--- pptp-1.7.2/pptp_gre.c.prototype 2011-12-06 16:41:47.392574067 +0000
++++ pptp-1.7.2/pptp_gre.c 2011-12-06 16:45:34.605691678 +0000
+@@ -71,7 +71,7 @@ void print_packet(int fd, void *pack, un
+ #endif
+
+ /*** time_now_usecs ***********************************************************/
+-uint64_t time_now_usecs()
++uint64_t time_now_usecs(void)
+ {
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+diff -up pptp-1.7.2/pptp_quirks.c.prototype pptp-1.7.2/pptp_quirks.c
+--- pptp-1.7.2/pptp_quirks.c.prototype 2008-05-14 07:33:55.000000000 +0100
++++ pptp-1.7.2/pptp_quirks.c 2011-12-06 16:41:47.405574074 +0000
+@@ -30,7 +30,7 @@ int set_quirk_index(int index)
+ return -1;
+ }
+
+-int get_quirk_index()
++int get_quirk_index(void)
+ {
+ return quirk_index;
+ }
+diff -up pptp-1.7.2/pptp_quirks.h.prototype pptp-1.7.2/pptp_quirks.h
+--- pptp-1.7.2/pptp_quirks.h.prototype 2008-05-14 07:33:55.000000000 +0100
++++ pptp-1.7.2/pptp_quirks.h 2011-12-06 16:41:47.406574074 +0000
+@@ -53,7 +53,7 @@ int set_quirk_index(int index);
+
+ /* get the global quirk index. return the index on success,
+ -1 if no quirk is defined */
+-int get_quirk_index();
++int get_quirk_index(void);
+
+
+ #endif /* INC_PPTP_QUIRKS_H */
+diff -up pptp-1.7.2/pqueue.c.prototype pptp-1.7.2/pqueue.c
+--- pptp-1.7.2/pqueue.c.prototype 2011-12-06 16:41:47.392574067 +0000
++++ pptp-1.7.2/pqueue.c 2011-12-06 16:41:47.406574074 +0000
+@@ -217,7 +217,7 @@ int pqueue_del (pqueue_t *point) {
+
+
+
+-pqueue_t *pqueue_head () {
++pqueue_t *pqueue_head (void) {
+ return pq_head;
+ }
+
+diff -up pptp-1.7.2/pqueue.h.prototype pptp-1.7.2/pqueue.h
+--- pptp-1.7.2/pqueue.h.prototype 2011-12-06 16:41:47.392574067 +0000
++++ pptp-1.7.2/pqueue.h 2011-12-06 16:41:47.407574075 +0000
+@@ -24,7 +24,7 @@ typedef struct pqueue {
+
+ int pqueue_add (u_int32_t seq, unsigned char *packet, int packlen);
+ int pqueue_del (pqueue_t *point);
+-pqueue_t *pqueue_head ();
++pqueue_t *pqueue_head (void);
+ int pqueue_expiry_time (pqueue_t *entry);
+
+ #endif /* PQUEUE_H */
+diff -up pptp-1.7.2/routing.c.prototype pptp-1.7.2/routing.c
+--- pptp-1.7.2/routing.c.prototype 2011-12-06 16:41:47.388574065 +0000
++++ pptp-1.7.2/routing.c 2011-12-06 16:41:47.407574075 +0000
+@@ -123,7 +123,7 @@ void routing_init(char *ip) {
+ #endif /* Solaris */
+ }
+
+-void routing_start() {
++void routing_start(void) {
+ #if defined (__SVR4) && defined (__sun) /* Solaris */
+ if ( ! dorouting )
+ return;
+@@ -153,7 +153,7 @@ void routing_start() {
+ #endif /* Solaris */
+ }
+
+-void routing_end() {
++void routing_end(void) {
+ #if defined (__SVR4) && defined (__sun) /* Solaris */
+ if ( ! dorouting)
+ return;
+diff -up pptp-1.7.2/routing.h.prototype pptp-1.7.2/routing.h
+--- pptp-1.7.2/routing.h.prototype 2008-05-14 07:33:55.000000000 +0100
++++ pptp-1.7.2/routing.h 2011-12-06 16:41:47.407574075 +0000
+@@ -1,3 +1,3 @@
+ void routing_init(char *ip);
+-void routing_start();
+-void routing_end();
++void routing_start(void);
++void routing_end(void);
+diff -up pptp-1.7.2/test.c.prototype pptp-1.7.2/test.c
+--- pptp-1.7.2/test.c.prototype 2011-12-06 16:41:47.393574067 +0000
++++ pptp-1.7.2/test.c 2011-12-06 16:41:47.408574076 +0000
+@@ -171,7 +171,7 @@ static ssize_t write_reordered(int fd, c
+ }
+ }
+
+-struct test_redirections *test_redirections()
++struct test_redirections *test_redirections(void)
+ {
+ static struct test_redirections *my = NULL;
+
+diff -up pptp-1.7.2/test.h.prototype pptp-1.7.2/test.h
+--- pptp-1.7.2/test.h.prototype 2008-05-14 07:33:55.000000000 +0100
++++ pptp-1.7.2/test.h 2011-12-06 16:41:47.408574076 +0000
+@@ -2,4 +2,4 @@ struct test_redirections {
+ ssize_t (*write)(int fd, const void *buf, size_t count);
+ };
+
+-struct test_redirections *test_redirections();
++struct test_redirections *test_redirections(void);
+diff -up pptp-1.7.2/util.c.prototype pptp-1.7.2/util.c
+--- pptp-1.7.2/util.c.prototype 2011-12-06 16:41:47.396574070 +0000
++++ pptp-1.7.2/util.c 2011-12-06 16:41:47.409574076 +0000
+@@ -87,7 +87,7 @@ int file2fd(const char *path, const char
+ static int sigpipe[2];
+
+ /* create a signal pipe, returns 0 for success, -1 with errno for failure */
+-int sigpipe_create()
++int sigpipe_create(void)
+ {
+ int rc;
+
+@@ -133,20 +133,20 @@ void sigpipe_assign(int signum)
+ }
+
+ /* return the signal pipe read file descriptor for select(2) */
+-int sigpipe_fd()
++int sigpipe_fd(void)
+ {
+ return sigpipe[0];
+ }
+
+ /* read and return the pending signal from the pipe */
+-int sigpipe_read()
++int sigpipe_read(void)
+ {
+ int signum;
+ read(sigpipe[0], &signum, sizeof(signum));
+ return signum;
+ }
+
+-void sigpipe_close()
++void sigpipe_close(void)
+ {
+ close(sigpipe[0]);
+ close(sigpipe[1]);
+diff -up pptp-1.7.2/util.h.prototype pptp-1.7.2/util.h
+--- pptp-1.7.2/util.h.prototype 2011-12-06 16:41:47.396574070 +0000
++++ pptp-1.7.2/util.h 2011-12-06 16:41:47.409574076 +0000
+@@ -35,7 +35,7 @@ int file2fd(const char *path, const char
+ /* signal to pipe delivery implementation */
+
+ /* create a signal pipe, returns 0 for success, -1 with errno for failure */
+-int sigpipe_create();
++int sigpipe_create(void);
+
+ /* generic handler for signals, writes signal number to pipe */
+ void sigpipe_handler(int signum);
+@@ -44,11 +44,11 @@ void sigpipe_handler(int signum);
+ void sigpipe_assign(int signum);
+
+ /* return the signal pipe read file descriptor for select(2) */
+-int sigpipe_fd();
++int sigpipe_fd(void);
+
+ /* read and return the pending signal from the pipe */
+-int sigpipe_read();
++int sigpipe_read(void);
+
+-void sigpipe_close();
++void sigpipe_close(void);
+
+ #endif /* INC_UTIL_H */
+diff -up pptp-1.7.2/vector.c.prototype pptp-1.7.2/vector.c
+--- pptp-1.7.2/vector.c.prototype 2008-05-14 07:33:55.000000000 +0100
++++ pptp-1.7.2/vector.c 2011-12-06 16:41:47.409574076 +0000
+@@ -35,7 +35,7 @@ struct vector_struct {
+ static struct vector_item *binary_search(VECTOR *v, int key);
+
+ /*** vector_create ************************************************************/
+-VECTOR *vector_create()
++VECTOR *vector_create(void)
+ {
+ const int INITIAL_SIZE = 4;
+
+diff -up pptp-1.7.2/vector.h.prototype pptp-1.7.2/vector.h
+--- pptp-1.7.2/vector.h.prototype 2008-05-14 07:33:55.000000000 +0100
++++ pptp-1.7.2/vector.h 2011-12-06 16:41:47.410574077 +0000
+@@ -12,7 +12,7 @@
+
+ typedef struct vector_struct VECTOR;
+
+-VECTOR *vector_create();
++VECTOR *vector_create(void);
+ void vector_destroy(VECTOR *v);
+
+ int vector_size(VECTOR *v);
diff --git a/pptp-1.7.2-sign-compare.patch b/pptp-1.7.2-sign-compare.patch
new file mode 100644
index 0000000..bb82904
--- /dev/null
+++ b/pptp-1.7.2-sign-compare.patch
@@ -0,0 +1,150 @@
+diff -up pptp-1.7.2/pptp_ctrl.c.sign-compare pptp-1.7.2/pptp_ctrl.c
+--- pptp-1.7.2/pptp_ctrl.c.sign-compare 2011-11-30 16:33:00.877964659 +0000
++++ pptp-1.7.2/pptp_ctrl.c 2011-11-30 18:49:17.603973525 +0000
+@@ -193,7 +193,7 @@ int ctrlp_disp(PPTP_CONN * conn, void *
+ void pptp_set_link(PPTP_CONN * conn, int peer_call_id);
+
+ /*** log error information in control packets *********************************/
+-static void ctrlp_error( int result, int error, int cause,
++static void ctrlp_error( int result, u_int8_t error, int cause,
+ const char *result_text[], int max_result)
+ {
+ if( cause >= 0)
+@@ -238,7 +238,7 @@ static const char *ctrl_msg_types[] = {
+ #define MAX_CTRLMSG_TYPE 15
+
+ /*** report a sent packet ****************************************************/
+-static void ctrlp_rep( void * buffer, int size, int isbuff)
++static void ctrlp_rep( void * buffer, size_t size, int isbuff)
+ {
+ struct pptp_header *packet = buffer;
+ unsigned int type;
+@@ -532,7 +532,7 @@ int pptp_write_some(PPTP_CONN * conn) {
+ return -1;
+ }
+ }
+- assert(retval <= conn->write_size);
++ assert((size_t)retval <= conn->write_size);
+ conn->write_size -= retval;
+ memmove(conn->write_buffer, conn->write_buffer + retval, conn->write_size);
+ ctrlp_rep(conn->write_buffer, retval, 0);
+diff -up pptp-1.7.2/pptp_gre.c.sign-compare pptp-1.7.2/pptp_gre.c
+--- pptp-1.7.2/pptp_gre.c.sign-compare 2011-11-30 16:33:00.899964648 +0000
++++ pptp-1.7.2/pptp_gre.c 2011-11-30 16:33:00.911964643 +0000
+@@ -200,8 +200,7 @@ void pptp_gre_copy(u_int16_t call_id, u_
+ int decaps_hdlc(int fd, int (*cb)(int cl, void *pack, unsigned int len), int cl)
+ {
+ unsigned char buffer[PACKET_MAX];
+- unsigned int start = 0;
+- int end;
++ ssize_t start = 0, end;
+ int status;
+ static unsigned int len = 0, escape = 0;
+ static unsigned char copy[PACKET_MAX];
+@@ -210,7 +209,7 @@ int decaps_hdlc(int fd, int (*cb)(int cl
+ /* this is the only blocking read we will allow */
+ if ((end = read (fd, buffer, sizeof(buffer))) <= 0) {
+ int saved_errno = errno;
+- warn("short read (%d): %s", end, strerror(saved_errno));
++ warn("short read (%zd): %s", end, strerror(saved_errno));
+ switch (saved_errno) {
+ case EMSGSIZE: {
+ socklen_t optval, optlen = sizeof(optval);
+@@ -499,7 +498,7 @@ int encaps_gre (int fd, void *pack, unsi
+ if (errno == ENOBUFS)
+ rc = 0; /* Simply ignore it */
+ stats.tx_failed++;
+- } else if (rc < sizeof(u.header) - sizeof(u.header.seq)) {
++ } else if ((size_t)rc < sizeof(u.header) - sizeof(u.header.seq)) {
+ stats.tx_short++;
+ } else {
+ stats.tx_acks++;
+@@ -533,7 +532,7 @@ int encaps_gre (int fd, void *pack, unsi
+ if (errno == ENOBUFS)
+ rc = 0; /* Simply ignore it */
+ stats.tx_failed++;
+- } else if (rc < header_len + len) {
++ } else if ((size_t)rc < header_len + len) {
+ stats.tx_short++;
+ } else {
+ stats.tx_sent++;
+diff -up pptp-1.7.2/pqueue.c.sign-compare pptp-1.7.2/pqueue.c
+--- pptp-1.7.2/pqueue.c.sign-compare 2008-05-14 07:33:55.000000000 +0100
++++ pptp-1.7.2/pqueue.c 2011-11-30 16:41:39.598648652 +0000
+@@ -17,7 +17,7 @@
+
+ #define MIN_CAPACITY 128 /* min allocated buffer for a packet */
+
+-static int pqueue_alloc (int seq, unsigned char *packet, int packlen, pqueue_t **new);
++static int pqueue_alloc (u_int32_t seq, unsigned char *packet, int packlen, pqueue_t **new);
+
+ int packet_timeout_usecs = DEFAULT_PACKET_TIMEOUT * 1000000;
+
+@@ -29,7 +29,7 @@ static pqueue_t *pq_freelist_head = NULL
+
+
+
+-static int pqueue_alloc(int seq, unsigned char *packet, int packlen, pqueue_t **new) {
++static int pqueue_alloc(u_int32_t seq, unsigned char *packet, int packlen, pqueue_t **new) {
+
+ pqueue_t *newent;
+
+@@ -125,7 +125,7 @@ static int pqueue_alloc(int seq, unsigne
+
+
+
+-int pqueue_add (int seq, unsigned char *packet, int packlen) {
++int pqueue_add (u_int32_t seq, unsigned char *packet, int packlen) {
+ pqueue_t *newent, *point;
+
+ /* get a new entry */
+diff -up pptp-1.7.2/pqueue.h.sign-compare pptp-1.7.2/pqueue.h
+--- pptp-1.7.2/pqueue.h.sign-compare 2008-05-14 07:33:55.000000000 +0100
++++ pptp-1.7.2/pqueue.h 2011-11-30 18:42:16.733706666 +0000
+@@ -15,14 +15,14 @@ extern int packet_timeout_usecs;
+ typedef struct pqueue {
+ struct pqueue *next;
+ struct pqueue *prev;
+- int seq;
++ u_int32_t seq;
+ struct timeval expires;
+ unsigned char *packet;
+ int packlen;
+ int capacity;
+ } pqueue_t;
+
+-int pqueue_add (int seq, unsigned char *packet, int packlen);
++int pqueue_add (u_int32_t seq, unsigned char *packet, int packlen);
+ int pqueue_del (pqueue_t *point);
+ pqueue_t *pqueue_head ();
+ int pqueue_expiry_time (pqueue_t *entry);
+diff -up pptp-1.7.2/test.c.sign-compare pptp-1.7.2/test.c
+--- pptp-1.7.2/test.c.sign-compare 2008-05-14 07:33:55.000000000 +0100
++++ pptp-1.7.2/test.c 2011-11-30 18:45:44.553853995 +0000
+@@ -52,7 +52,7 @@ static ssize_t write_reordered_swap(int
+ test_ordering_phase = 0;
+ /* send the new packet first */
+ stat = write(fd, buf, count);
+- if (stat != count) return stat;
++ if ((size_t)stat != count) return stat;
+ /* then send the old packet next */
+ stat = write(fd, pocket_buf, pocket_count);
+ free(pocket_buf);
+@@ -96,7 +96,7 @@ static ssize_t write_reordered_retransmi
+ test_ordering_phase = 0;
+ /* send the new packet first */
+ stat = write(fd, buf, count);
+- if (stat != count) return stat;
++ if ((size_t)stat != count) return stat;
+ /* send the buffered packets in normal order */
+ for (n=0; n<test_length; n++) {
+ stat = write(fd, pocket_buf[n], pocket_count[n]);
+@@ -142,7 +142,7 @@ static ssize_t write_reordered_reverse(i
+ test_ordering_phase = 0;
+ /* send the new packet first */
+ stat = write(fd, buf, count);
+- if (stat != count) return stat;
++ if ((size_t)stat != count) return stat;
+ /* send the buffered packets in reverse order */
+ for (n=test_length-1; n>0; n--) {
+ stat = write(fd, pocket_buf[n], pocket_count[n]);
diff --git a/pptp-1.7.2-unused.patch b/pptp-1.7.2-unused.patch
new file mode 100644
index 0000000..635cd73
--- /dev/null
+++ b/pptp-1.7.2-unused.patch
@@ -0,0 +1,73 @@
+diff -up pptp-1.7.2/pptp_callmgr.c.unused pptp-1.7.2/pptp_callmgr.c
+--- pptp-1.7.2/pptp_callmgr.c.unused 2011-12-01 09:58:47.127960697 +0000
++++ pptp-1.7.2/pptp_callmgr.c 2011-12-01 09:58:47.149960723 +0000
+@@ -38,12 +38,12 @@ void close_unixsock(int fd, struct in_ad
+
+ sigjmp_buf callmgr_env;
+
+-void callmgr_sighandler(int sig) {
++void callmgr_sighandler(int sig __attribute__ ((unused))) {
+ /* TODO: according to signal(2), siglongjmp() is unsafe used here */
+ siglongjmp (callmgr_env, 1);
+ }
+
+-void callmgr_do_nothing(int sig) {
++void callmgr_do_nothing(int sig __attribute__ ((unused))) {
+ /* do nothing signal handler */
+ }
+
+@@ -104,7 +104,7 @@ void call_callback(PPTP_CONN *conn, PPTP
+ *****************************************************************************/
+
+ /*** Call Manager *************************************************************/
+-int callmgr_main(int argc, char **argv, char **envp)
++int callmgr_main(int argc, char **argv, char **envp __attribute__ ((unused)))
+ {
+ struct in_addr inetaddr;
+ int inet_sock, unix_sock;
+@@ -377,7 +377,7 @@ int open_unixsock(struct in_addr inetadd
+ }
+
+ /*** close_inetsock ***********************************************************/
+-void close_inetsock(int fd, struct in_addr inetaddr)
++void close_inetsock(int fd, struct in_addr inetaddr __attribute__ ((unused)))
+ {
+ close(fd);
+ }
+diff -up pptp-1.7.2/pptp.c.unused pptp-1.7.2/pptp.c
+--- pptp-1.7.2/pptp.c.unused 2011-12-01 09:58:47.143960715 +0000
++++ pptp-1.7.2/pptp.c 2011-12-01 10:01:40.171147875 +0000
+@@ -151,13 +151,13 @@ void do_nothing(int sig)
+ sigjmp_buf env;
+
+ /*** signal handler ***********************************************************/
+-void sighandler(int sig)
++void sighandler(int sig __attribute__ ((unused)))
+ {
+ siglongjmp(env, 1);
+ }
+
+ /*** report statistics signal handler (SIGUSR1) *******************************/
+-void sigstats(int sig)
++void sigstats(int sig __attribute__ ((unused)))
+ {
+ syslog(LOG_NOTICE, "GRE statistics:\n");
+ #define LOG(name,value) syslog(LOG_NOTICE, name "\n", stats .value)
+@@ -508,7 +508,7 @@ int open_callmgr(struct in_addr inetaddr
+ }
+
+ /*** call the call manager main ***********************************************/
+-void launch_callmgr(struct in_addr inetaddr, char *phonenr, int argc,
++void launch_callmgr(struct in_addr inetaddr, char *phonenr, int argc __attribute__ ((unused)),
+ char**argv,char**envp)
+ {
+ char *my_argv[3] = { argv[0], inet_ntoa(inetaddr), phonenr };
+@@ -566,7 +566,7 @@ void launch_pppd(char *ttydev, int argc,
+ {
+ char *new_argv[argc + 4];/* XXX if not using GCC, hard code a limit here. */
+ char str_pppd[] = PPPD_BINARY;
+- char str_direct[] = "-direct";
++ char str_direct[] __attribute__ ((unused)) = "-direct";
+ char str_38400[] = "38400";
+ int i = 0, j;
+ new_argv[i++] = str_pppd;
diff --git a/pptp.spec b/pptp.spec
index fa02066..da1fd67 100644
--- a/pptp.spec
+++ b/pptp.spec
@@ -1,6 +1,6 @@
Name: pptp
Version: 1.7.2
-Release: 13.1%{?dist}
+Release: 13.2%{?dist}
Summary: Point-to-Point Tunneling Protocol (PPTP) Client
Group: Applications/Internet
License: GPLv2+
@@ -20,6 +20,14 @@ Patch9: pptp-1.7.2-call-disconnect-notify.patch
Patch10: pptp-1.7.2-so_mark.patch
Patch11: pptp-1.7.2-nohostroute-option.patch
Patch12: pptp-1.7.2-parallel-build.patch
+Patch13: pptp-1.7.2-fsf-update.patch
+Patch101: pptp-1.7.2-sign-compare.patch
+Patch102: pptp-1.7.2-const.patch
+Patch103: pptp-1.7.2-field-init.patch
+Patch104: pptp-1.7.2-unused.patch
+Patch105: pptp-1.7.2-prototype.patch
+Patch106: pptp-1.7.2-nested-externs.patch
+Patch107: pptp-1.7.2-aliasing.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -nu)
Requires: ppp >= 2.4.2, /sbin/ip
%if 0%{?fedora} > 14
@@ -84,12 +92,36 @@ tunnels.
# Implement the --nohostroute option that routing.c talks about (upstream patch)
%patch11 -p1 -b .nohostroute
+# Update the FSF address references and GPLv2 license text (upstream patch)
+%patch13 -p0 -b .fsf
+
+# Fix comparisons between signed and unsigned integers
+%patch101 -p1 -b .sign-compare
+
+# Fix const usage
+%patch102 -p1 -b .const
+
+# Add missing field initializers
+%patch103 -p1 -b .field
+
+# Suppress warnings about possibly unused variables
+%patch104 -p1 -b .unused
+
+# Fix declarations that are not prototypes
+%patch105 -p1 -b .prototype
+
+# Fix warnings about nested externs
+%patch106 -p1 -b .nested
+
+# Fix aliasing issues
+%patch107 -p1 -b .alias
+
# Pacify rpmlint
perl -pi -e 's/install -o root -m 555 pptp/install -m 755 pptp/;' Makefile
%build
-OUR_CFLAGS="$(echo X%{optflags} | sed -e 's/^X//; s/-O[0-9]* /-O0 /')"
-make %{?_smp_mflags} CFLAGS="-Wall $OUR_CFLAGS" IP=/sbin/ip
+OUR_CFLAGS="-Wall %{optflags} -Wextra -Wstrict-aliasing=2 -Wnested-externs -Wstrict-prototypes"
+make %{?_smp_mflags} CFLAGS="$OUR_CFLAGS" IP=/sbin/ip
%install
rm -rf %{buildroot}
@@ -126,6 +158,19 @@ rm -rf %{buildroot}
%{_mandir}/man8/pptpsetup.8*
%changelog
+* Wed Nov 30 2011 Paul Howarth <paul at city-fan.org> 1.7.2-13.2
+- Add patch to fix highly-parallel build (e.g. -j16)
+- Add additional compiler warning flags to highlight questionable code
+- Add patch to fix comparisons between signed and unsigned integers
+- Add patch to fix const usage
+- Add patch to fix missing field initializers
+- Add patch to suppress warnings about possibly unused variables
+- Add patch to fix declarations that are not prototypes
+- Add patch to fix warnings about nested externs
+- Add patch to fix dubious typecasts that violate strict-aliasing rules
+- Update the FSF address references and GPLv2 license text
+- Use default optimization level (-O2) again
+
* Fri Nov 11 2011 Paul Howarth <paul at city-fan.org> 1.7.2-13.1
- Drop compiler optimization level to -O0 as per upstream in attempt to
resolve occasional segfault in pptpcm (#749455)
More information about the scm-commits
mailing list