Re: openssh portable on FreeBSD i386

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



My inclination would be to just make the timeout signed to match
time_t.  No need for ugly casts then and parse_timeout() parses the
number as an int anyway (rejecting negative values).  As far as I
can see there is no way for these values to be larger than an int.

 - todd

Index: channels.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/channels.c,v
retrieving revision 1.430
diff -u -p -u -r1.430 channels.c
--- channels.c	10 Mar 2023 03:01:51 -0000	1.430
+++ channels.c	1 Jun 2023 16:32:38 -0000
@@ -146,7 +146,7 @@ struct permission_set {
 /* Used to record timeouts per channel type */
 struct ssh_channel_timeout {
 	char *type_pattern;
-	u_int timeout_secs;
+	int timeout_secs;
 };
 
 /* Master structure for channels state */
@@ -304,11 +304,11 @@ channel_lookup(struct ssh *ssh, int id)
  */
 void
 channel_add_timeout(struct ssh *ssh, const char *type_pattern,
-    u_int timeout_secs)
+    int timeout_secs)
 {
 	struct ssh_channels *sc = ssh->chanctxt;
 
-	debug2_f("channel type \"%s\" timeout %u seconds",
+	debug2_f("channel type \"%s\" timeout %d seconds",
 	    type_pattern, timeout_secs);
 	sc->timeouts = xrecallocarray(sc->timeouts, sc->ntimeouts,
 	    sc->ntimeouts + 1, sizeof(*sc->timeouts));
@@ -332,7 +332,7 @@ channel_clear_timeouts(struct ssh *ssh)
 	sc->ntimeouts = 0;
 }
 
-static u_int
+static int
 lookup_timeout(struct ssh *ssh, const char *type)
 {
 	struct ssh_channels *sc = ssh->chanctxt;
Index: channels.h
===================================================================
RCS file: /cvs/src/usr.bin/ssh/channels.h,v
retrieving revision 1.149
diff -u -p -u -r1.149 channels.h
--- channels.h	4 Mar 2023 03:22:59 -0000	1.149
+++ channels.h	1 Jun 2023 16:28:59 -0000
@@ -207,7 +207,7 @@ struct Channel {
 	/* Last traffic seen for OPEN channels */
 	time_t			lastused;
 	/* Inactivity timeout deadline in seconds (0 = no timeout) */
-	u_int			inactive_deadline;
+	int			inactive_deadline;
 };
 
 #define CHAN_EXTENDED_IGNORE		0
@@ -305,7 +305,7 @@ int	 channel_close_fd(struct ssh *, Chan
 void	 channel_send_window_changes(struct ssh *);
 
 /* channel inactivity timeouts */
-void channel_add_timeout(struct ssh *, const char *, u_int);
+void channel_add_timeout(struct ssh *, const char *, int);
 void channel_clear_timeouts(struct ssh *);
 
 /* mux proxy support */
Index: servconf.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/servconf.c,v
retrieving revision 1.393
diff -u -p -u -r1.393 servconf.c
--- servconf.c	24 May 2023 23:01:06 -0000	1.393
+++ servconf.c	1 Jun 2023 16:31:34 -0000
@@ -908,7 +908,7 @@ process_permitopen(struct ssh *ssh, Serv
 
 /* Parse a ChannelTimeout clause "pattern=interval" */
 static int
-parse_timeout(const char *s, char **typep, u_int *secsp)
+parse_timeout(const char *s, char **typep, int *secsp)
 {
 	char *cp, *sdup;
 	int secs;
@@ -934,7 +934,7 @@ parse_timeout(const char *s, char **type
 	if (typep != NULL)
 		*typep = xstrdup(sdup);
 	if (secsp != NULL)
-		*secsp = (u_int)secs;
+		*secsp = secs;
 	free(sdup);
 	return 0;
 }
@@ -942,7 +942,8 @@ parse_timeout(const char *s, char **type
 void
 process_channel_timeouts(struct ssh *ssh, ServerOptions *options)
 {
-	u_int i, secs;
+	int secs;
+	u_int i;
 	char *type;
 
 	debug3_f("setting %u timeouts", options->num_channel_timeouts);
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev



[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux