drop patches included upstream and modify existing for new upstream

This commit is contained in:
Jan Wagner 2007-12-06 13:39:25 +00:00
parent 1cd5a5ef84
commit a5760cde1a
6 changed files with 49 additions and 256 deletions

View file

@ -3,11 +3,7 @@
14_check_log_paths.dpatch 14_check_log_paths.dpatch
18_check_game_cmdline.dpatch 18_check_game_cmdline.dpatch
22_check_smb_hostaddress.dpatch 22_check_smb_hostaddress.dpatch
23_check_axis.dpatch
25_check_tcp-expect.dpatch
26_implicit-basename.dpatch 26_implicit-basename.dpatch
27_check_radius_segfault.dpatch 27_check_radius_segfault.dpatch
28_configure_typo.dpatch
CVE-2007-5198.dpatch
CVE-2007-5623.dpatch CVE-2007-5623.dpatch
50_misc_typos.dpatch 50_misc_typos.dpatch

View file

@ -1,24 +0,0 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 23_check_axis.dpatch by Marc Haber <mh+debian-packages@zugschlus.de>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.
@DPATCH@
diff -urNad trunk~/contrib/check_axis.sh trunk/contrib/check_axis.sh
--- trunk~/contrib/check_axis.sh 2003-05-26 10:09:23.000000000 +0000
+++ trunk/contrib/check_axis.sh 2006-01-20 19:00:46.000000000 +0000
@@ -29,9 +29,11 @@
status=`echo $lines | awk '{ print $3 }'`
if [ "$status" == "Printing" ]; then
bytes=`echo $lines | awk '{ print $4 }'`;
- comments=`echo $lines | tr -d " " | awk '{ print $5 " " $6 }'`;
+ comments=`echo $lines | tr -d "
+" | awk '{ print $5 " " $6 }'`;
else
- comments=`echo $lines | tr -d " " | awk '{ print $4 " " $5 }'`;
+ comments=`echo $lines | tr -d "
+" | awk '{ print $4 " " $5 }'`;
fi
comma=`echo $comments | grep , | wc -l`

View file

@ -1,18 +0,0 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 25_check_tcp-expect.dpatch by <seanius@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.
@DPATCH@
diff -urNad nagios-plugins-1.4.4~/plugins/check_tcp.c nagios-plugins-1.4.4/plugins/check_tcp.c
--- nagios-plugins-1.4.4~/plugins/check_tcp.c 2006-09-02 22:32:27.000000000 +0200
+++ nagios-plugins-1.4.4/plugins/check_tcp.c 2006-11-01 22:20:43.000000000 +0100
@@ -494,7 +494,6 @@
asprintf(&server_send, "%s", optarg);
break;
case 'e': /* expect string (may be repeated) */
- EXPECT = NULL;
flags &= ~FLAG_EXACT_MATCH;
if (server_expect_count == 0)
server_expect = malloc (sizeof (char *) * (++server_expect_count));

View file

@ -1,19 +0,0 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 28_configure_typo.dpatch by <sean@rangda.stickybit.se>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.
@DPATCH@
diff -urNad sid~/configure sid/configure
--- sid~/configure 2007-04-11 14:12:37.000000000 +0200
+++ sid/configure 2007-05-27 22:11:41.000000000 +0200
@@ -21447,7 +21447,7 @@
{ echo "$as_me:$LINENO: WARNING: install mysql client libs to compile this plugin (see REQUIREMENTS)." >&5
echo "$as_me: WARNING: install mysql client libs to compile this plugin (see REQUIREMENTS)." >&2;}
else
- EXTRAS="$EXTRA check_mysql check_mysql_query"
+ EXTRAS="$EXTRAS check_mysql check_mysql_query"
MYSQLINCLUDE="$np_mysql_include"
MYSQLLIBS="$np_mysql_libs"
MYSQLCFLAGS="$np_mysql_cflags"

View file

@ -1,14 +1,15 @@
#! /bin/sh /usr/share/dpatch/dpatch-run #! /bin/sh /usr/share/dpatch/dpatch-run
## 50_misc_typos.dpatch by <andy@andrewprice.me.uk> ## 50_misc_typos.dpatch by <andy@andrewprice.me.uk> modified for 1.4.10 by
## Jan Wagner <waja@cyconet.org>
## ##
## All lines beginning with `## DP:' are a description of the patch. ## All lines beginning with `## DP:' are a description of the patch.
## DP: This patch fixes various typos and grammatical errors in plugins/*.c. ## DP: This patch fixes various typos and grammatical errors in plugins/*.c.
## DP: It is based on Malcolm Parsons' patch posted at https://launchpad.net/bugs/64595 ## DP: It is based on Malcolm Parsons' patch posted at https://launchpad.net/bugs/64595
@DPATCH@ @DPATCH@
diff -urNad nagios-plugins-1.4.8~/plugins/check_dns.c nagios-plugins-1.4.8/plugins/check_dns.c diff -Nur nagios-plugins-1.4.10.orig/plugins/check_dns.c nagios-plugins-1.4.10/plugins/check_dns.c
--- nagios-plugins-1.4.8~/plugins/check_dns.c 2007-01-28 21:46:40.000000000 +0000 --- nagios-plugins-1.4.10.orig/plugins/check_dns.c 2007-01-28 22:46:41.000000000 +0100
+++ nagios-plugins-1.4.8/plugins/check_dns.c 2007-06-17 17:00:18.000000000 +0100 +++ nagios-plugins-1.4.10/plugins/check_dns.c 2007-12-06 14:17:22.000000000 +0100
@@ -218,7 +218,7 @@ @@ -218,7 +218,7 @@
printf (_("DNS CRITICAL - %s\n"), printf (_("DNS CRITICAL - %s\n"),
!strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg); !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg);
@ -18,28 +19,28 @@ diff -urNad nagios-plugins-1.4.8~/plugins/check_dns.c nagios-plugins-1.4.8/plugi
!strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg); !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg);
return result; return result;
diff -urNad nagios-plugins-1.4.8~/plugins/check_http.c nagios-plugins-1.4.8/plugins/check_http.c diff -Nur nagios-plugins-1.4.10.orig/plugins/check_http.c nagios-plugins-1.4.10/plugins/check_http.c
--- nagios-plugins-1.4.8~/plugins/check_http.c 2007-03-06 22:45:57.000000000 +0000 --- nagios-plugins-1.4.10.orig/plugins/check_http.c 2007-07-21 18:29:01.000000000 +0200
+++ nagios-plugins-1.4.8/plugins/check_http.c 2007-06-17 17:28:18.000000000 +0100 +++ nagios-plugins-1.4.10/plugins/check_http.c 2007-12-06 14:18:47.000000000 +0100
@@ -1084,7 +1084,7 @@ @@ -1089,7 +1089,7 @@
url = malloc (strcspn (pos, "\r\n")); url = malloc (strcspn (pos, "\r\n"));
if (url == NULL) if (url == NULL)
- die (STATE_UNKNOWN, _("Could not allocate url\n")); - die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate url\n"));
+ die (STATE_UNKNOWN, _("Could not allocate URL\n")); + die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate URL\n"));
while (pos) { while (pos) {
sscanf (pos, "%[Ll]%*[Oo]%*[Cc]%*[Aa]%*[Tt]%*[Ii]%*[Oo]%*[Nn]:%n", xx, &i); sscanf (pos, "%[Ll]%*[Oo]%*[Cc]%*[Aa]%*[Tt]%*[Ii]%*[Oo]%*[Nn]:%n", xx, &i);
@@ -1103,7 +1103,7 @@ @@ -1120,7 +1120,7 @@
url = realloc (url, strcspn (pos, "\r\n")); url = realloc (url, strcspn (pos, "\r\n") + 1);
if (url == NULL) if (url == NULL)
- die (STATE_UNKNOWN, _("could not allocate url\n")); - die (STATE_UNKNOWN, _("HTTP UNKNOWN - could not allocate url\n"));
+ die (STATE_UNKNOWN, _("could not allocate URL\n")); + die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate URL\n"));
/* URI_HTTP, URI_HOST, URI_PORT, URI_PATH */ /* URI_HTTP, URI_HOST, URI_PORT, URI_PATH */
if (sscanf (pos, HD1, type, addr, port, url) == 4) { if (sscanf (pos, HD1, type, addr, &i, url) == 4)
@@ -1259,7 +1259,7 @@ @@ -1287,7 +1287,7 @@
printf (" %s\n", _("Connect via SSL. Port defaults to 443")); printf (" %s\n", _("Connect via SSL. Port defaults to 443"));
printf (" %s\n", "-C, --certificate=INTEGER"); printf (" %s\n", "-C, --certificate=INTEGER");
printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443")); printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443"));
@ -48,21 +49,21 @@ diff -urNad nagios-plugins-1.4.8~/plugins/check_http.c nagios-plugins-1.4.8/plug
#endif #endif
printf (" %s\n", "-e, --expect=STRING"); printf (" %s\n", "-e, --expect=STRING");
diff -urNad nagios-plugins-1.4.8~/plugins/check_ldap.c nagios-plugins-1.4.8/plugins/check_ldap.c diff -Nur nagios-plugins-1.4.10.orig/plugins/check_ldap.c nagios-plugins-1.4.10/plugins/check_ldap.c
--- nagios-plugins-1.4.8~/plugins/check_ldap.c 2007-01-28 21:46:40.000000000 +0000 --- nagios-plugins-1.4.10.orig/plugins/check_ldap.c 2007-07-08 00:20:40.000000000 +0200
+++ nagios-plugins-1.4.8/plugins/check_ldap.c 2007-06-17 17:03:03.000000000 +0100 +++ nagios-plugins-1.4.10/plugins/check_ldap.c 2007-12-06 14:19:23.000000000 +0100
@@ -184,7 +184,7 @@ @@ -191,7 +191,7 @@
if (ldap_bind_s (ld, ld_binddn, ld_passwd, LDAP_AUTH_SIMPLE) !=
LDAP_SUCCESS) { LDAP_SUCCESS) {
/*ldap_perror(ld, "ldap_bind"); */ if (verbose)
ldap_perror(ld, "ldap_bind");
- printf (_("Could not bind to the ldap-server\n")); - printf (_("Could not bind to the ldap-server\n"));
+ printf (_("Could not bind to the LDAP server\n")); + printf (_("Could not bind to the LDAP server\n"));
return STATE_CRITICAL; return STATE_CRITICAL;
} }
diff -urNad nagios-plugins-1.4.8~/plugins/check_mysql.c nagios-plugins-1.4.8/plugins/check_mysql.c diff -Nur nagios-plugins-1.4.10.orig/plugins/check_mysql.c nagios-plugins-1.4.10/plugins/check_mysql.c
--- nagios-plugins-1.4.8~/plugins/check_mysql.c 2007-03-29 18:58:28.000000000 +0100 --- nagios-plugins-1.4.10.orig/plugins/check_mysql.c 2007-03-29 19:58:28.000000000 +0200
+++ nagios-plugins-1.4.8/plugins/check_mysql.c 2007-06-17 17:09:27.000000000 +0100 +++ nagios-plugins-1.4.10/plugins/check_mysql.c 2007-12-06 14:19:57.000000000 +0100
@@ -370,7 +370,7 @@ @@ -370,7 +370,7 @@
printf (_(COPYRIGHT), copyright, email); printf (_(COPYRIGHT), copyright, email);
@ -72,9 +73,9 @@ diff -urNad nagios-plugins-1.4.8~/plugins/check_mysql.c nagios-plugins-1.4.8/plu
printf ("\n\n"); printf ("\n\n");
diff -urNad nagios-plugins-1.4.8~/plugins/check_procs.c nagios-plugins-1.4.8/plugins/check_procs.c diff -Nur nagios-plugins-1.4.10.orig/plugins/check_procs.c nagios-plugins-1.4.10/plugins/check_procs.c
--- nagios-plugins-1.4.8~/plugins/check_procs.c 2007-03-06 17:29:15.000000000 +0000 --- nagios-plugins-1.4.10.orig/plugins/check_procs.c 2007-07-15 17:21:51.000000000 +0200
+++ nagios-plugins-1.4.8/plugins/check_procs.c 2007-06-17 17:16:34.000000000 +0100 +++ nagios-plugins-1.4.10/plugins/check_procs.c 2007-12-06 14:22:31.000000000 +0100
@@ -690,7 +690,7 @@ @@ -690,7 +690,7 @@
printf (" %s\n", _("PROCS - number of processes (default)")); printf (" %s\n", _("PROCS - number of processes (default)"));
printf (" %s\n", _("VSZ - virtual memory size")); printf (" %s\n", _("VSZ - virtual memory size"));
@ -111,10 +112,10 @@ diff -urNad nagios-plugins-1.4.8~/plugins/check_procs.c nagios-plugins-1.4.8/plu
printf (_(UT_SUPPORT)); printf (_(UT_SUPPORT));
} }
diff -urNad nagios-plugins-1.4.8~/plugins/check_radius.c nagios-plugins-1.4.8/plugins/check_radius.c diff -Nur nagios-plugins-1.4.10.orig/plugins/check_radius.c nagios-plugins-1.4.10/plugins/check_radius.c
--- nagios-plugins-1.4.8~/plugins/check_radius.c 2007-01-28 21:46:40.000000000 +0000 --- nagios-plugins-1.4.10.orig/plugins/check_radius.c 2007-09-26 12:57:44.000000000 +0200
+++ nagios-plugins-1.4.8/plugins/check_radius.c 2007-06-17 17:18:58.000000000 +0100 +++ nagios-plugins-1.4.10/plugins/check_radius.c 2007-12-06 14:24:05.000000000 +0100
@@ -302,7 +302,7 @@ @@ -311,7 +311,7 @@
printf ("Copyright (c) 1999 Robert August Vincent II\n"); printf ("Copyright (c) 1999 Robert August Vincent II\n");
printf (COPYRIGHT, copyright, email); printf (COPYRIGHT, copyright, email);
@ -123,7 +124,7 @@ diff -urNad nagios-plugins-1.4.8~/plugins/check_radius.c nagios-plugins-1.4.8/pl
printf ("\n\n"); printf ("\n\n");
@@ -327,16 +327,16 @@ @@ -336,16 +336,16 @@
printf (_(UT_TIMEOUT), timeout_interval); printf (_(UT_TIMEOUT), timeout_interval);
@ -143,10 +144,10 @@ diff -urNad nagios-plugins-1.4.8~/plugins/check_radius.c nagios-plugins-1.4.8/pl
printf (_(UT_SUPPORT)); printf (_(UT_SUPPORT));
} }
diff -urNad nagios-plugins-1.4.8~/plugins/check_snmp.c nagios-plugins-1.4.8/plugins/check_snmp.c diff -Nur nagios-plugins-1.4.10.orig/plugins/check_snmp.c nagios-plugins-1.4.10/plugins/check_snmp.c
--- nagios-plugins-1.4.8~/plugins/check_snmp.c 2007-02-02 09:10:22.000000000 +0000 --- nagios-plugins-1.4.10.orig/plugins/check_snmp.c 2007-05-29 07:22:32.000000000 +0200
+++ nagios-plugins-1.4.8/plugins/check_snmp.c 2007-06-17 17:21:46.000000000 +0100 +++ nagios-plugins-1.4.10/plugins/check_snmp.c 2007-12-06 14:25:18.000000000 +0100
@@ -906,7 +906,7 @@ @@ -917,7 +917,7 @@
printf (COPYRIGHT, copyright, email); printf (COPYRIGHT, copyright, email);
@ -155,7 +156,7 @@ diff -urNad nagios-plugins-1.4.8~/plugins/check_snmp.c nagios-plugins-1.4.8/plug
printf ("\n\n"); printf ("\n\n");
@@ -941,8 +941,8 @@ @@ -952,8 +952,8 @@
printf (" %s\n", "-o, --oid=OID(s)"); printf (" %s\n", "-o, --oid=OID(s)");
printf (" %s\n", _("Object identifier(s) or SNMP variables whose value you wish to query")); printf (" %s\n", _("Object identifier(s) or SNMP variables whose value you wish to query"));
printf (" %s\n", "-m, --miblist=STRING"); printf (" %s\n", "-m, --miblist=STRING");
@ -166,10 +167,10 @@ diff -urNad nagios-plugins-1.4.8~/plugins/check_snmp.c nagios-plugins-1.4.8/plug
printf (" %s\n", "-d, --delimiter=STRING"); printf (" %s\n", "-d, --delimiter=STRING");
printf (_(" Delimiter to use when parsing returned data. Default is \"%s\""), DEFAULT_DELIMITER); printf (_(" Delimiter to use when parsing returned data. Default is \"%s\""), DEFAULT_DELIMITER);
printf (" %s\n", _("Any data on the right hand side of the delimiter is considered")); printf (" %s\n", _("Any data on the right hand side of the delimiter is considered"));
diff -urNad nagios-plugins-1.4.8~/plugins/check_tcp.c nagios-plugins-1.4.8/plugins/check_tcp.c diff -Nur nagios-plugins-1.4.10.orig/plugins/check_tcp.c nagios-plugins-1.4.10/plugins/check_tcp.c
--- nagios-plugins-1.4.8~/plugins/check_tcp.c 2007-02-14 10:11:06.000000000 +0000 --- nagios-plugins-1.4.10.orig/plugins/check_tcp.c 2007-06-03 16:40:13.000000000 +0200
+++ nagios-plugins-1.4.8/plugins/check_tcp.c 2007-06-17 17:22:10.000000000 +0100 +++ nagios-plugins-1.4.10/plugins/check_tcp.c 2007-12-06 14:25:56.000000000 +0100
@@ -623,7 +623,7 @@ @@ -621,7 +621,7 @@
printf (" %s\n", "-q, --quit=STRING"); printf (" %s\n", "-q, --quit=STRING");
printf (" %s\n", _("String to send server to initiate a clean close of the connection")); printf (" %s\n", _("String to send server to initiate a clean close of the connection"));
printf (" %s\n", "-r, --refuse=ok|warn|crit"); printf (" %s\n", "-r, --refuse=ok|warn|crit");
@ -178,9 +179,9 @@ diff -urNad nagios-plugins-1.4.8~/plugins/check_tcp.c nagios-plugins-1.4.8/plugi
printf (" %s\n", "-M, --mismatch=ok|warn|crit"); printf (" %s\n", "-M, --mismatch=ok|warn|crit");
printf (" %s\n", _("Accept expected string mismatches with states ok, warn, crit (default: warn)")); printf (" %s\n", _("Accept expected string mismatches with states ok, warn, crit (default: warn)"));
printf (" %s\n", "-j, --jail"); printf (" %s\n", "-j, --jail");
diff -urNad nagios-plugins-1.4.8~/plugins/check_ups.c nagios-plugins-1.4.8/plugins/check_ups.c diff -Nur nagios-plugins-1.4.10.orig/plugins/check_ups.c nagios-plugins-1.4.10/plugins/check_ups.c
--- nagios-plugins-1.4.8~/plugins/check_ups.c 2007-01-28 21:46:41.000000000 +0000 --- nagios-plugins-1.4.10.orig/plugins/check_ups.c 2007-05-09 11:16:33.000000000 +0200
+++ nagios-plugins-1.4.8/plugins/check_ups.c 2007-06-17 17:26:33.000000000 +0100 +++ nagios-plugins-1.4.10/plugins/check_ups.c 2007-12-06 14:27:26.000000000 +0100
@@ -416,7 +416,7 @@ @@ -416,7 +416,7 @@
len = strlen(ptr); len = strlen(ptr);
if (len > 0 && ptr[len-1] == '\n') ptr[len-1]=0; if (len > 0 && ptr[len-1] == '\n') ptr[len-1]=0;
@ -199,7 +200,7 @@ diff -urNad nagios-plugins-1.4.8~/plugins/check_ups.c nagios-plugins-1.4.8/plugi
return ERROR; return ERROR;
} }
return OK; return OK;
@@ -631,7 +631,7 @@ @@ -635,7 +635,7 @@
printf ("%s\n", _("This plugin attempts to determine the status of a UPS (Uninterruptible Power")); printf ("%s\n", _("This plugin attempts to determine the status of a UPS (Uninterruptible Power"));
printf ("%s\n", _("Supply) on a local or remote host. If the UPS is online or calibrating, the")); printf ("%s\n", _("Supply) on a local or remote host. If the UPS is online or calibrating, the"));
printf ("%s\n", _("plugin will return an OK state. If the battery is on it will return a WARNING")); printf ("%s\n", _("plugin will return an OK state. If the battery is on it will return a WARNING"));
@ -208,7 +209,7 @@ diff -urNad nagios-plugins-1.4.8~/plugins/check_ups.c nagios-plugins-1.4.8/plugi
printf ("%s\n\n", _("state.")); printf ("%s\n\n", _("state."));
printf ("%s\n", _("You may also specify a variable to check [such as temperature, utility voltage,")); printf ("%s\n", _("You may also specify a variable to check [such as temperature, utility voltage,"));
@@ -639,7 +639,7 @@ @@ -643,7 +643,7 @@
printf ("%s\n", _("that variable. If the remote host has multiple UPS that are being monitored you")); printf ("%s\n", _("that variable. If the remote host has multiple UPS that are being monitored you"));
printf ("%s\n", _("will have to use the [ups] option to specify which UPS to check.")); printf ("%s\n", _("will have to use the [ups] option to specify which UPS to check."));

View file

@ -1,143 +0,0 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## CVE-2007-5198.dpatch
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fixes CVE-2007-5198
@DPATCH@
diff -urNad nagios-plugins-1.4.8~/plugins/check_http.c nagios-plugins-1.4.8/plugins/check_http.c
--- nagios-plugins-1.4.8~/plugins/check_http.c 2007-03-06 23:45:57.000000000 +0100
+++ nagios-plugins-1.4.8/plugins/check_http.c 2007-10-28 16:25:01.000000000 +0100
@@ -53,7 +53,8 @@
enum {
MAX_IPV4_HOSTLENGTH = 255,
HTTP_PORT = 80,
- HTTPS_PORT = 443
+ HTTPS_PORT = 443,
+ MAX_PORT = 65535
};
#ifdef HAVE_SSL
@@ -148,7 +149,7 @@
if (display_html == TRUE)
printf ("<A HREF=\"%s://%s:%d%s\" target=\"_blank\">",
- use_ssl ? "https" : "http", host_name,
+ use_ssl ? "https" : "http", server_address,
server_port, server_url);
/* initialize alarm signal handling, set socket timeout, start timer */
@@ -1057,14 +1058,14 @@
/* per RFC 2396 */
#define HDR_LOCATION "%*[Ll]%*[Oo]%*[Cc]%*[Aa]%*[Tt]%*[Ii]%*[Oo]%*[Nn]: "
-#define URI_HTTP "%[HTPShtps]://"
-#define URI_HOST "%[-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]"
-#define URI_PORT ":%[0123456789]"
+#define URI_HTTP "%5[HTPShtps]"
+#define URI_HOST "%255[-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]"
+#define URI_PORT "%6d" /* MAX_PORT's width is 5 chars, 6 to detect overflow */
#define URI_PATH "%[-_.!~*'();/?:@&=+$,%#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]"
-#define HD1 URI_HTTP URI_HOST URI_PORT URI_PATH
-#define HD2 URI_HTTP URI_HOST URI_PATH
-#define HD3 URI_HTTP URI_HOST URI_PORT
-#define HD4 URI_HTTP URI_HOST
+#define HD1 URI_HTTP "://" URI_HOST ":" URI_PORT "/" URI_PATH
+#define HD2 URI_HTTP "://" URI_HOST "/" URI_PATH
+#define HD3 URI_HTTP "://" URI_HOST ":" URI_PORT
+#define HD4 URI_HTTP "://" URI_HOST
#define HD5 URI_PATH
void
@@ -1075,7 +1076,6 @@
char xx[2];
char type[6];
char *addr;
- char port[6];
char *url;
addr = malloc (MAX_IPV4_HOSTLENGTH + 1);
@@ -1087,7 +1087,7 @@
die (STATE_UNKNOWN, _("Could not allocate url\n"));
while (pos) {
- sscanf (pos, "%[Ll]%*[Oo]%*[Cc]%*[Aa]%*[Tt]%*[Ii]%*[Oo]%*[Nn]:%n", xx, &i);
+ sscanf (pos, "%1[Ll]%*[Oo]%*[Cc]%*[Aa]%*[Tt]%*[Ii]%*[Oo]%*[Nn]:%n", xx, &i);
if (i == 0) {
pos += (size_t) strcspn (pos, "\r\n");
pos += (size_t) strspn (pos, "\r\n");
@@ -1099,17 +1099,21 @@
}
pos += i;
- pos += strspn (pos, " \t\r\n");
+ pos += strspn (pos, " \t");
+ for (; (i = strspn (pos, "\r\n")); pos += i) {
+ pos += i;
+ if (!(i = strspn (pos, " \t"))) {
+ die (STATE_UNKNOWN, _("HTTP UNKNOWN - Empty redirect location%s\n"),display_html ? "</A>" : "");
+ }
+ }
- url = realloc (url, strcspn (pos, "\r\n"));
+ url = realloc (url, strcspn (pos, "\r\n")+ 1);
if (url == NULL)
die (STATE_UNKNOWN, _("could not allocate url\n"));
/* URI_HTTP, URI_HOST, URI_PORT, URI_PATH */
- if (sscanf (pos, HD1, type, addr, port, url) == 4) {
+ if (sscanf (pos, HD1, type, addr, &i, url) == 4)
use_ssl = server_type_check (type);
- i = atoi (port);
- }
/* URI_HTTP URI_HOST URI_PATH */
else if (sscanf (pos, HD2, type, addr, url) == 3 ) {
@@ -1118,10 +1122,9 @@
}
/* URI_HTTP URI_HOST URI_PORT */
- else if(sscanf (pos, HD3, type, addr, port) == 3) {
+ else if(sscanf (pos, HD3, type, addr, &i) == 3) {
strcpy (url, HTTP_URL);
use_ssl = server_type_check (type);
- i = atoi (port);
}
/* URI_HTTP URI_HOST */
@@ -1141,7 +1144,7 @@
}
i = server_port;
strcpy (type, server_type);
- strcpy (addr, host_name);
+ strcpy (addr, server_address);
}
else {
@@ -1167,7 +1170,6 @@
_("WARNING - redirection creates an infinite loop - %s://%s:%d%s%s\n"),
type, addr, i, url, (display_html ? "</A>" : ""));
- server_port = i;
strcpy (server_type, type);
free (host_name);
@@ -1177,7 +1179,18 @@
server_address = strdup (addr);
free (server_url);
+ if ((url[0] == '/'))
server_url = strdup (url);
+ else if (asprintf(&server_url, "/%s", url) == -1)
+ die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate server_url%s\n"), display_html ? "</A>" : "");
+ free(url);
+
+ if ((server_port = i) > MAX_PORT)
+ die (STATE_UNKNOWN, _("HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n"),
+ MAX_PORT, server_type, server_address, server_port, server_url, display_html ? "</A>" : "");
+
+ if (verbose)
+ printf ("Redirection to %s://%s:%d%s\n", server_type, server_address, server_port, server_url);
check_http ();
}