aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2008-12-16 00:46:46 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2008-12-16 00:46:46 +0200
commitaa283a0d2b5ed5cbad76036c6fb0e5e7f0496bc2 (patch)
treeb50c31a962e95932f70266c429aba3db9b6d9f65
parent47b7a2ab5e6da5582f2a85486dc72ced34c45e18 (diff)
downloadradius-aa283a0d2b5ed5cbad76036c6fb0e5e7f0496bc2.tar.gz
radius-aa283a0d2b5ed5cbad76036c6fb0e5e7f0496bc2.tar.bz2
Bugfix.
* lib/list.c (grad_list_destroy): Zero *plist before actually freeing its contents. This makes list destroying an atomical operation. In particular, it is important when destroying _grad_debug_list.
-rw-r--r--lib/list.c12
-rw-r--r--tests/findport.c185
-rw-r--r--tests/raddb/client.conf.in2
-rw-r--r--tests/raddb/realms.in2
4 files changed, 9 insertions, 192 deletions
diff --git a/lib/list.c b/lib/list.c
index f86b4b26..dd671e5e 100644
--- a/lib/list.c
+++ b/lib/list.c
@@ -55,11 +55,14 @@ void
grad_list_destroy(struct grad_list **plist, list_iterator_t user_free, void *data)
{
struct grad_list_entry *p;
-
+ struct grad_list *list;
+
if (!*plist)
return;
-
- p = (*plist)->head;
+
+ list = *plist;
+ *plist = NULL;
+ p = list->head;
while (p) {
struct grad_list_entry *next = p->next;
if (user_free)
@@ -67,8 +70,7 @@ grad_list_destroy(struct grad_list **plist, list_iterator_t user_free, void *dat
grad_free(p);
p = next;
}
- grad_free(*plist);
- *plist = NULL;
+ grad_free(list);
}
void *
diff --git a/tests/findport.c b/tests/findport.c
deleted file mode 100644
index 0589665b..00000000
--- a/tests/findport.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/* This file is part of GNU Radius.
- Copyright (C) 2001,2003,2007 Free Software Foundation, Inc.
-
- Written by Sergey Poznyakoff
-
- GNU Radius is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- GNU Radius is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- 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 GNU Radius; if not, write to the Free
- Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301 USA. */
-
-/*
- * This program is a part of test suite. It determines first N available
- * UDP ports to be used.
- * usage: findport [-c N][-s P][-m P][-f F]
- * Options are:
- * -c N Find first N not-used ports (default 1)
- * -s P Start from port P+1 (default 1024)
- * -m P Finish when port P is reached (default 65535)
- * -f F Use format string F for output.
- * Any subsequent occurence of characters %d in format string is replaced
- * with the found port number. Usual C backslash sequences are recognized.
- * All other characters encountered in format string are reproduced
- * verbatim.
- * If no format string is specified, the port numbers are printed one per
- * line of output.
- * Return value: 0 if OK, 1 on error.
- * Bugs: No check is made to ensure that the number of %d markers in format
- * string coincides with number N.
- */
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-#include <pwd.h>
-
-char *format = NULL;
-
-char *
-who_am_i()
-{
- struct passwd *pw = getpwuid(getuid());
- if (pw)
- return pw->pw_name;
- return "nobody";
-}
-
-void
-output(int port)
-{
- if (!format) {
- if (port)
- printf("%d\n", port);
- return;
- }
-
- while (*format) {
- if (port && format[0] == '%' && format[1] == 'd') {
- printf("%d", port);
- format += 2;
- break;
- } else if (format[0] == '%' && format[1] == 'u') {
- printf("%s", who_am_i());
- format += 2;
- } else if (format[0] == '\\' && format[1]) {
- switch (format[1]) {
- case 'a':
- putchar('\a');
- break;
- case 'b':
- putchar('\b');
- break;
- case 'n':
- putchar('\n');
- break;
- case 't':
- putchar('\t');
- break;
- case 'v':
- putchar('\v');
- break;
- case '\\':
- putchar('\\');
- break;
- default:
- putchar(format[0]);
- putchar(format[2]);
- break;
- }
- format += 2;
- } else
- putchar(*format++);
- }
-}
-
-int
-main(int argc, char **argv)
-{
- char *progname = argv[0];
- int local_port, max_port, num_ports;
- struct sockaddr salocal;
- struct sockaddr_in *sin;
- int fd;
-
- /* Process command line */
- local_port = 1024;
- max_port = 65535;
- num_ports = 1;
-
-#define OPTARG (*argv)[2] ? *argv+2 : *++argv
- while (*++argv) {
- if (**argv == '-') {
- switch ((*argv)[1]) {
- case 's':
- local_port = atoi(OPTARG);
- break;
- case 'm':
- max_port = atoi(OPTARG);
- break;
- case 'c':
- num_ports = atoi(OPTARG);
- break;
- case 'f':
- format = OPTARG;
- break;
- default:
- fprintf(stderr,
- "%s: unknown switch: %s\n",
- progname, *argv);
- return 1;
- }
- } else {
- fprintf(stderr,
- "%s: stray argument %s\n", progname, *argv);
- return 1;
- }
- }
-
- while (num_ports--) {
- fd = socket(AF_INET, SOCK_DGRAM, 0);
- if (fd < 0) {
- fprintf(stderr,
- "%s: can't open socket: %d\n",
- progname, errno);
- return 1;
- }
-
- sin = (struct sockaddr_in *) &salocal;
- memset(sin, 0, sizeof (salocal));
- sin->sin_family = AF_INET;
- sin->sin_addr.s_addr = INADDR_ANY;
-
- do {
- if (++local_port > max_port) {
- fprintf(stderr, "%s: can't bind socket\n",
- progname);
- return 1;
- }
- sin->sin_port = htons((u_short)local_port);
- } while ((bind(fd, &salocal, sizeof(struct sockaddr_in)) < 0) &&
- local_port < max_port);
- output(local_port);
- close(fd);
- }
- output(0);
- return 0;
-}
-
diff --git a/tests/raddb/client.conf.in b/tests/raddb/client.conf.in
index 957295c9..ea1bcbba 100644
--- a/tests/raddb/client.conf.in
+++ b/tests/raddb/client.conf.in
@@ -1,3 +1,3 @@
-server local 127.0.0.1 foobar @TEST_AUTH_PORT@ @TEST_ACCT_PORT@
+server local 127.0.0.1 foobar {AUTH} {ACCT}
timeout 3
retry 1
diff --git a/tests/raddb/realms.in b/tests/raddb/realms.in
index 8a9cae85..1d4f725f 100644
--- a/tests/raddb/realms.in
+++ b/tests/raddb/realms.in
@@ -1,4 +1,4 @@
# Realm Remote server [:port:[port]] flags
#---------------- --------------------- --------
local LOCAL strip
-remote 127.0.0.2:@PROXY_AUTH_PORT@:@PROXY_ACCT_PORT@
+remote 127.0.0.2:{PROXY_AUTH}:{PROXY_ACCT}

Return to:

Send suggestions and report system problems to the System administrator.