diff options
| author | Paul Traina <pst@FreeBSD.org> | 1997-01-18 08:35:17 +0000 |
|---|---|---|
| committer | Paul Traina <pst@FreeBSD.org> | 1997-01-18 08:35:17 +0000 |
| commit | 972b9cf163a0d74c7fef23e6feea1dd32fddc5c9 (patch) | |
| tree | 962bc5d66f99454701b46a684fdcfa379bdce0ff /libexec/talkd | |
| parent | 7c5e88b7dc44f07959c7d0282b9fba59848c7264 (diff) | |
Notes
Diffstat (limited to 'libexec/talkd')
| -rw-r--r-- | libexec/talkd/announce.c | 39 | ||||
| -rw-r--r-- | libexec/talkd/talkd.c | 3 |
2 files changed, 25 insertions, 17 deletions
diff --git a/libexec/talkd/announce.c b/libexec/talkd/announce.c index db03bbfb8618..0a3733bc34b0 100644 --- a/libexec/talkd/announce.c +++ b/libexec/talkd/announce.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)announce.c 8.2 (Berkeley) 1/7/94"; +static char sccsid[] = "@(#)announce.c 8.3 (Berkeley) 4/28/95"; #endif /* not lint */ #include <sys/types.h> @@ -41,15 +41,18 @@ static char sccsid[] = "@(#)announce.c 8.2 (Berkeley) 1/7/94"; #include <sys/time.h> #include <sys/wait.h> #include <sys/socket.h> + #include <protocols/talkd.h> -#include <sgtty.h> + #include <errno.h> -#include <syslog.h> -#include <unistd.h> +#include <paths.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> -#include <paths.h> - +#include <syslog.h> +#include <unistd.h> +#include <vis.h> + extern char hostname[]; /* @@ -77,7 +80,7 @@ announce(request, remote_machine) #define max(a,b) ( (a) > (b) ? (a) : (b) ) #define N_LINES 5 -#define N_CHARS 120 +#define N_CHARS 256 /* * Build a block of characters containing the message. @@ -99,33 +102,37 @@ print_mesg(tty, tf, request, remote_machine) char line_buf[N_LINES][N_CHARS]; int sizes[N_LINES]; char big_buf[N_LINES*N_CHARS]; - char *bptr, *lptr, *ttymsg(); + char *bptr, *lptr, *vis_user; int i, j, max_size; i = 0; max_size = 0; gettimeofday(&clock, &zone); localclock = localtime( &clock.tv_sec ); - (void)sprintf(line_buf[i], " "); + (void)snprintf(line_buf[i], N_CHARS, " "); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); i++; - (void)sprintf(line_buf[i], "Message from Talk_Daemon@%s at %d:%02d ...", - hostname, localclock->tm_hour , localclock->tm_min ); + (void)snprintf(line_buf[i], N_CHARS, + "Message from Talk_Daemon@%s at %d:%02d ...", + hostname, localclock->tm_hour , localclock->tm_min ); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); i++; - (void)sprintf(line_buf[i], "talk: connection requested by %s@%s", - request->l_name, remote_machine); + + vis_user = malloc(strlen(request->l_name) * 4 + 1); + strvis(vis_user, request->l_name, VIS_CSTYLE); + (void)snprintf(line_buf[i], N_CHARS, + "talk: connection requested by %s@%s", vis_user, remote_machine); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); i++; - (void)sprintf(line_buf[i], "talk: respond with: talk %s@%s", - request->l_name, remote_machine); + (void)snprintf(line_buf[i], N_CHARS, "talk: respond with: talk %s@%s", + vis_user, remote_machine); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); i++; - (void)sprintf(line_buf[i], " "); + (void)snprintf(line_buf[i], N_CHARS, " "); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); i++; diff --git a/libexec/talkd/talkd.c b/libexec/talkd/talkd.c index 9fd595016208..a686e301f9e4 100644 --- a/libexec/talkd/talkd.c +++ b/libexec/talkd/talkd.c @@ -69,7 +69,7 @@ int debug = 0; void timeout(); long lastmsgtime; -char hostname[MAXHOSTNAMELEN]; +char hostname[MAXHOSTNAMELEN + 1]; #define TIMEOUT 30 #define MAXIDLE 120 @@ -110,6 +110,7 @@ main(argc, argv) lastmsgtime = time(0); process_request(mp, &response); /* can block here, is this what I want? */ + mp->ctl_addr.sa_family = htons(mp->ctl_addr.sa_family); cc = sendto(sockt, (char *)&response, sizeof (response), 0, (struct sockaddr *)&mp->ctl_addr, sizeof (mp->ctl_addr)); |
