Control: tags -1 + patch upstream
On Mon, Feb 17, 2025 at 05:56:27PM +0000, Matthias Klose wrote:
> misc.c:37:12: error: too many arguments to function ‘fgets’; expected 0, have
> 3
> 37 | while (fgets(ptr, len, fp)) {
> | ^~~~~ ~~~
> misc.c:21:14: note: declared here
> 21 | extern char *fgets();
> | ^~~~~
Generally, the code base likes to use unspecified arguments in function
prototypes and that's incompatible with C23. I'm attaching a patch that
extends the underspecified prototypes and makes the code build with
gcc-15.
Helmut
--- tcp-wrappers-7.6.q.orig/misc.c
+++ tcp-wrappers-7.6.q/misc.c
@@ -18,8 +18,6 @@
#include "tcpd.h"
-extern char *fgets();
-
#ifndef INADDR_NONE
#define INADDR_NONE (-1) /* XXX should be 0xffffffff */
#endif
--- tcp-wrappers-7.6.q.orig/hosts_access.c
+++ tcp-wrappers-7.6.q/hosts_access.c
@@ -44,7 +44,6 @@
#include <netdb.h>
#endif
-extern char *fgets();
extern int errno;
#ifndef INADDR_NONE
@@ -92,17 +91,17 @@
/* Forward declarations. */
-static int table_match();
-static int list_match();
-static int server_match();
-static int client_match();
-static int host_match();
-static int string_match();
-static int masked_match();
-static int match_pattern_ylo();
+static int table_match(char *, struct request_info *);
+static int list_match(char *, struct request_info *, int (*)(char *, struct request_info *));
+static int server_match(char *, struct request_info *);
+static int client_match(char *, struct request_info *);
+static int host_match(char *, struct host_info *);
+static int string_match(char *, char *);
+static int masked_match(char *, char *, char *);
+static int match_pattern_ylo(const char *, const char *);
#ifdef INET6
-static int masked_match4();
-static int masked_match6();
+static int masked_match4(char *, char *, char *);
+static int masked_match6(char *, char *, char *);
#endif
/* Size of logical line buffer. */
@@ -216,7 +215,7 @@
static int list_match(list, request, match_fn)
char *list;
struct request_info *request;
-int (*match_fn) ();
+int (*match_fn) (char *, struct request_info *);
{
char *tok;
@@ -305,7 +304,7 @@
static int hostfile_match(path, host)
char *path;
-struct hosts_info *host;
+struct host_info *host;
{
char tok[BUFSIZ];
int match = NO;
--- tcp-wrappers-7.6.q.orig/options.c
+++ tcp-wrappers-7.6.q/options.c
@@ -69,32 +69,32 @@
static char whitespace_eq[] = "= \t\r\n";
#define whitespace (whitespace_eq + 1)
-static char *get_field(); /* chew :-delimited field off string */
-static char *chop_string(); /* strip leading and trailing blanks */
+static char *get_field(char *); /* chew :-delimited field off string */
+static char *chop_string(register char *);/* strip leading and trailing blanks */
/* List of functions that implement the options. Add yours here. */
-static void user_option(); /* execute "user name.group" option */
-static void group_option(); /* execute "group name" option */
-static void umask_option(); /* execute "umask mask" option */
-static void linger_option(); /* execute "linger time" option */
-static void keepalive_option(); /* execute "keepalive" option */
-static void aclexec_option(); /* execute "aclexec command" option */
-static void spawn_option(); /* execute "spawn command" option */
-static void twist_option(); /* execute "twist command" option */
-static void rfc931_option(); /* execute "rfc931" option */
-static void setenv_option(); /* execute "setenv name value" */
-static void nice_option(); /* execute "nice" option */
-static void severity_option(); /* execute "severity value" */
-static void allow_option(); /* execute "allow" option */
-static void deny_option(); /* execute "deny" option */
-static void banners_option(); /* execute "banners path" option */
+static void user_option(char *, struct request_info *);/* execute "user name.group" option */
+static void group_option(char *, struct request_info *);/* execute "group name" option */
+static void umask_option(char *, struct request_info *);/* execute "umask mask" option */
+static void linger_option(char *, struct request_info *);/* execute "linger time" option */
+static void keepalive_option(char *, struct request_info *);/* execute "keepalive" option */
+static void aclexec_option(char *, struct request_info *);/* execute "aclexec command" option */
+static void spawn_option(char *, struct request_info *);/* execute "spawn command" option */
+static void twist_option(char *, struct request_info *);/* execute "twist command" option */
+static void rfc931_option(char *, struct request_info *);/* execute "rfc931" option */
+static void setenv_option(char *, struct request_info *);/* execute "setenv name value" */
+static void nice_option(char *, struct request_info *);/* execute "nice" option */
+static void severity_option(char *, struct request_info *);/* execute "severity value" */
+static void allow_option(char *, struct request_info *);/* execute "allow" option */
+static void deny_option(char *, struct request_info *);/* execute "deny" option */
+static void banners_option(char *, struct request_info *);/* execute "banners path" option */
/* Structure of the options table. */
struct option {
char *name; /* keyword name, case is ignored */
- void (*func) (); /* function that does the real work */
+ void (*func) (char *, struct request_info *);/* function that does the real work */
int flags; /* see below... */
};
@@ -257,7 +257,6 @@
struct request_info *request;
{
struct group *grp;
- struct group *getgrnam();
if ((grp = getgrnam(value)) == 0)
tcpd_jump("unknown group: \"%s\"", value);
@@ -280,7 +279,6 @@
struct request_info *request;
{
struct passwd *pwd;
- struct passwd *getpwnam();
char *group;
int defaultgroup = 0;
--- tcp-wrappers-7.6.q.orig/shell_cmd.c
+++ tcp-wrappers-7.6.q/shell_cmd.c
@@ -14,6 +14,7 @@
/* System libraries. */
+#include <stdlib.h>
#include <sys/types.h>
#include <sys/param.h>
#include <signal.h>
@@ -26,15 +27,13 @@
#include <sys/stat.h>
#include <fcntl.h>
-extern void exit();
-
/* Local stuff. */
#include "tcpd.h"
/* Forward declarations. */
-static void do_child();
+static void do_child(char *);
/*
* The sigchld handler. If there is a SIGCHLD caused by a child other than
--- tcp-wrappers-7.6.q.orig/percent_x.c
+++ tcp-wrappers-7.6.q/percent_x.c
@@ -16,13 +16,12 @@
/* System libraries. */
+#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <syslog.h>
#include <string.h>
-extern void exit();
-
/* Local stuff. */
#include "tcpd.h"
--- tcp-wrappers-7.6.q.orig/clean_exit.c
+++ tcp-wrappers-7.6.q/clean_exit.c
@@ -12,11 +12,10 @@
static char sccsid[] = "@(#) clean_exit.c 1.4 94/12/28 17:42:19";
#endif
+#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
-extern void exit();
-
#include "tcpd.h"
/* clean_exit - clean up and exit */
--- tcp-wrappers-7.6.q.orig/socket.c
+++ tcp-wrappers-7.6.q/socket.c
@@ -38,7 +38,7 @@
#define NI_WITHSCOPEID 0
#endif
#else
-extern char *inet_ntoa();
+extern char *inet_ntoa(struct in_addr *);
#endif
/* Local stuff. */
@@ -47,7 +47,7 @@
/* Forward declarations. */
-static void sock_sink();
+static void sock_sink(int);
#ifdef APPEND_DOT
--- tcp-wrappers-7.6.q.orig/mystdarg.h
+++ tcp-wrappers-7.6.q/mystdarg.h
@@ -16,4 +16,4 @@
#define VAEND(ap) va_end(ap);}
#endif
-extern char *percent_m();
+extern char *percent_m(char *, const char *);
--- tcp-wrappers-7.6.q.orig/scaffold.h
+++ tcp-wrappers-7.6.q/scaffold.h
@@ -5,9 +5,9 @@
*/
#ifdef INET6
-extern struct addrinfo *find_inet_addr();
+extern struct addrinfo *find_inet_addr(char *);
#else
-extern struct hostent *find_inet_addr();
+extern struct hostent *find_inet_addr(char *);
#endif
-extern int check_dns();
-extern int check_path();
+extern int check_dns(char *);
+extern int check_path(char *, struct stat *);
--- tcp-wrappers-7.6.q.orig/tcpdmatch.c
+++ tcp-wrappers-7.6.q/tcpdmatch.c
@@ -25,13 +25,13 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
+#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <syslog.h>
#include <setjmp.h>
#include <string.h>
-extern void exit();
extern int optind;
extern char *optarg;
@@ -49,8 +49,8 @@
#include "inetcf.h"
#include "scaffold.h"
-static void usage();
-static void tcpdmatch();
+static void usage(char *);
+static void tcpdmatch(struct request_info *);
/* The main program */
--- tcp-wrappers-7.6.q.orig/inetcf.h
+++ tcp-wrappers-7.6.q/inetcf.h
@@ -4,9 +4,9 @@
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
*/
-extern char *inet_cfg(); /* read inetd.conf file */
-extern void inet_set(); /* remember internet service */
-extern int inet_get(); /* look up internet service */
+extern char *inet_cfg(char *); /* read inetd.conf file */
+extern void inet_set(const char *, int);/* remember internet service */
+extern int inet_get(const char *); /* look up internet service */
#define WR_UNKNOWN (-1) /* service unknown */
#define WR_NOT 1 /* may not be wrapped */
--- tcp-wrappers-7.6.q.orig/inetcf.c
+++ tcp-wrappers-7.6.q/inetcf.c
@@ -17,7 +17,6 @@
#include <string.h>
extern int errno;
-extern void exit();
#include "tcpd.h"
#include "inetcf.h"
@@ -42,8 +41,8 @@
0,
};
-static void inet_chk();
-static char *base_name();
+static void inet_chk(char *, char *, char *, char *);
+static char *base_name(char *);
/*
* Structure with everything we know about a service.
@@ -72,7 +71,7 @@
char *arg0;
char *arg1;
struct tcpd_context saved_context;
- char *percent_m();
+ char *percent_m(char *, const char *);
int i;
struct stat st;
@@ -275,7 +274,7 @@
/* inet_set - remember service status */
void inet_set(name, type)
-char *name;
+const char *name;
int type;
{
struct inet_ent *ip =
@@ -294,7 +293,7 @@
/* inet_get - look up service status */
int inet_get(name)
-char *name;
+const char *name;
{
struct inet_ent *ip;
--- tcp-wrappers-7.6.q.orig/percent_m.c
+++ tcp-wrappers-7.6.q/percent_m.c
@@ -22,10 +22,10 @@
char *percent_m(obuf, ibuf)
char *obuf;
-char *ibuf;
+const char *ibuf;
{
char *bp = obuf;
- char *cp = ibuf;
+ const char *cp = ibuf;
while (*bp = *cp)
if (*cp == '%' && cp[1] == 'm') {
--- tcp-wrappers-7.6.q.orig/safe_finger.c
+++ tcp-wrappers-7.6.q/safe_finger.c
@@ -33,8 +33,6 @@
#include <grp.h>
#include <syslog.h>
-extern void exit();
-
/* Local stuff */
char path[] = "PATH=/bin:/usr/bin:/sbin:/usr/sbin";
--- tcp-wrappers-7.6.q.orig/tcpdchk.c
+++ tcp-wrappers-7.6.q/tcpdchk.c
@@ -37,7 +37,6 @@
#include <string.h>
extern int errno;
-extern void exit();
extern int optind;
extern char *optarg;
@@ -92,14 +91,14 @@
* Local stuff.
*/
static void usage();
-static void parse_table();
-static void print_list();
-static void check_daemon_list();
-static void check_client_list();
-static void check_daemon();
-static void check_user();
-static int check_host();
-static int reserved_name();
+static void parse_table(char *, struct request_info *);
+static void print_list(const char *, char *);
+static void check_daemon_list(char *);
+static void check_client_list(char *);
+static void check_daemon(char *);
+static void check_user(char *);
+static int check_host(char *);
+static int reserved_name(char *);
#define PERMIT 1
#define DENY 0
@@ -292,7 +291,7 @@
/* print_list - pretty-print a list */
static void print_list(title, list)
-char *title;
+const char *title;
char *list;
{
char buf[BUFLEN];