summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkstailey <kstailey@openbsd.org>1997-06-02 21:33:27 +0000
committerkstailey <kstailey@openbsd.org>1997-06-02 21:33:27 +0000
commit60bc1fb77e9ecf6c62e8f95293c3650c14cea20e (patch)
tree9e6f601361500a76034fed48990eaa1a9dcf9f04
parentFix for amd: make yp_order return YP_NOMAP for maps with '/' in them. (diff)
downloadwireguard-openbsd-60bc1fb77e9ecf6c62e8f95293c3650c14cea20e.tar.xz
wireguard-openbsd-60bc1fb77e9ecf6c62e8f95293c3650c14cea20e.zip
do strvis()ing in sprint.c
-rw-r--r--usr.bin/finger/extern.h3
-rw-r--r--usr.bin/finger/sprint.c13
-rw-r--r--usr.bin/finger/util.c27
3 files changed, 34 insertions, 9 deletions
diff --git a/usr.bin/finger/extern.h b/usr.bin/finger/extern.h
index 475f9d4f352..bc0497f6406 100644
--- a/usr.bin/finger/extern.h
+++ b/usr.bin/finger/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.3 1997/05/30 23:35:50 kstailey Exp $ */
+/* $OpenBSD: extern.h,v 1.4 1997/06/02 21:33:27 kstailey Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -61,5 +61,6 @@ void sflag_print __P((void));
int show_text __P((char *, char *, char *));
PERSON **sort __P((void));
void stimeprint __P((WHERE *));
+char *vs __P((char *));
void userlist __P((int, char **));
void vputc __P((int));
diff --git a/usr.bin/finger/sprint.c b/usr.bin/finger/sprint.c
index f7300cf55dc..b112a4efa5a 100644
--- a/usr.bin/finger/sprint.c
+++ b/usr.bin/finger/sprint.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sprint.c,v 1.3 1997/05/30 23:35:52 kstailey Exp $ */
+/* $OpenBSD: sprint.c,v 1.4 1997/06/02 21:33:27 kstailey Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@@ -38,7 +38,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)sprint.c 5.8 (Berkeley) 12/4/90";*/
-static char rcsid[] = "$OpenBSD: sprint.c,v 1.3 1997/05/30 23:35:52 kstailey Exp $";
+static char rcsid[] = "$OpenBSD: sprint.c,v 1.4 1997/06/02 21:33:27 kstailey Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -85,8 +85,8 @@ sflag_print()
pn = list[cnt];
for (w = pn->whead; w != NULL; w = w->next) {
(void)printf("%-*.*s %-*.*s ", UT_NAMESIZE, UT_NAMESIZE,
- pn->name, MAXREALNAME, MAXREALNAME,
- pn->realname ? pn->realname : "");
+ vs(pn->name), MAXREALNAME, MAXREALNAME,
+ pn->realname ? vs(pn->realname) : "");
if (!w->loginat) {
(void)printf(" * * No logins ");
goto office;
@@ -117,12 +117,13 @@ office:
putchar(' ');
if (oflag) {
if (pn->office)
- (void)printf("%-10.10s", pn->office);
+ (void)printf("%-10.10s",
+ vs(pn->office));
else if (pn->officephone)
(void)printf("%-10.10s", " ");
if (pn->officephone)
(void)printf(" %-.15s",
- prphone(pn->officephone));
+ vs(prphone(pn->officephone)));
} else
(void)printf("%.*s", MAXHOSTNAME, w->host);
putchar('\n');
diff --git a/usr.bin/finger/util.c b/usr.bin/finger/util.c
index 422c5313f1a..24c6b95facf 100644
--- a/usr.bin/finger/util.c
+++ b/usr.bin/finger/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.5 1997/05/30 23:35:53 kstailey Exp $ */
+/* $OpenBSD: util.c,v 1.6 1997/06/02 21:33:28 kstailey Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@@ -39,7 +39,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)util.c 5.14 (Berkeley) 1/17/91";*/
-static char rcsid[] = "$OpenBSD: util.c,v 1.5 1997/05/30 23:35:53 kstailey Exp $";
+static char rcsid[] = "$OpenBSD: util.c,v 1.6 1997/06/02 21:33:28 kstailey Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -47,6 +47,7 @@ static char rcsid[] = "$OpenBSD: util.c,v 1.5 1997/05/30 23:35:53 kstailey Exp $
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/file.h>
+#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
@@ -54,6 +55,7 @@ static char rcsid[] = "$OpenBSD: util.c,v 1.5 1997/05/30 23:35:53 kstailey Exp $
#include <paths.h>
#include <errno.h>
#include <unistd.h>
+#include <vis.h>
#include "finger.h"
#include "extern.h"
@@ -378,3 +380,24 @@ prphone(num)
*p = '\0';
return(pbuf);
}
+
+/* Like strvis(), but use malloc() to get the space and return a pointer
+ * to the beginning of the converted string, not the end.
+ *
+ * Recycle the malloc()ed area on each call. This leads to a leak which
+ * does not grow.
+ */
+char *
+vs(src)
+ char *src;
+{
+ static char *dst = NULL;
+
+ if (dst != NULL)
+ free(dst);
+ if ((dst = malloc((4 * strlen(src)) + 1)) == NULL)
+ err(1, "malloc failed");
+
+ strvis(dst, src, VIS_SAFE|VIS_NOSLASH);
+ return(dst);
+}