=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/finger/util.c,v retrieving revision 1.21 retrieving revision 1.22 diff -c -r1.21 -r1.22 *** src/usr.bin/finger/util.c 2005/03/15 12:28:48 1.21 --- src/usr.bin/finger/util.c 2005/08/23 13:43:53 1.22 *************** *** 1,4 **** ! /* $OpenBSD: util.c,v 1.21 2005/03/15 12:28:48 niallo Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. --- 1,4 ---- ! /* $OpenBSD: util.c,v 1.22 2005/08/23 13:43:53 espie Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. *************** *** 35,41 **** #ifndef lint /*static char sccsid[] = "from: @(#)util.c 5.14 (Berkeley) 1/17/91";*/ ! static const char rcsid[] = "$OpenBSD: util.c,v 1.21 2005/03/15 12:28:48 niallo Exp $"; #endif /* not lint */ #include --- 35,41 ---- #ifndef lint /*static char sccsid[] = "from: @(#)util.c 5.14 (Berkeley) 1/17/91";*/ ! static const char rcsid[] = "$OpenBSD: util.c,v 1.22 2005/08/23 13:43:53 espie Exp $"; #endif /* not lint */ #include *************** *** 61,67 **** --- 61,84 ---- void find_idle_and_ttywrite(WHERE *); void userinfo(PERSON *, struct passwd *); + struct storage { + struct storage *next; + char a[1]; + }; + void + free_storage(struct storage *st) + { + struct storage *nx; + + while (st != NULL) { + nx = st->next; + free(st); + st = nx; + } + } + + void find_idle_and_ttywrite(WHERE *w) { struct stat sb; *************** *** 376,387 **** * The caller is responsible for free()'ing the returned string. */ char * ! vs(char *src) { char *dst; ! if ((dst = malloc((4 * strlen(src)) + 1)) == NULL) err(1, "malloc failed"); strvis(dst, src, VIS_SAFE|VIS_NOSLASH); return (dst); --- 393,409 ---- * The caller is responsible for free()'ing the returned string. */ char * ! vs(struct storage **exist, char *src) { char *dst; + struct storage *n; ! if ((n = malloc(sizeof(struct storage) + 4 * strlen(src))) == NULL) err(1, "malloc failed"); + n->next = *exist; + *exist = n; + + dst = n->a; strvis(dst, src, VIS_SAFE|VIS_NOSLASH); return (dst);