percent_x.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* percent_x() takes a string and performs %<char> expansions. It aborts the
* program when the expansion would overflow the output buffer. The result
* of %<char> expansion may be passed on to a shell process. For this
* reason, characters with a special meaning to shells are replaced by
* underscores.
*
* Diagnostics are reported through syslog(3).
*
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
*/
#ifndef lint
static char sccsid[] = "@(#) percent_x.c 1.4 94/12/28 17:42:37";
#endif
/* System libraries. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#include <string.h>
extern void exit();
/* Local stuff. */
#include "tcpd.h"
/* percent_x - do %<char> expansion, abort if result buffer is too small */
char *result;
int result_len;
char *string;
struct request_info *request;
{
char *expansion;
int expansion_len;
static char ok_chars[] = "1234567890!@%-_=+:,./\
abcdefghijklmnopqrstuvwxyz\
ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char *cp;
int ch;
/*
* Warning: we may be called from a child process or after pattern
* matching, so we cannot use clean_exit() or tcpd_jump().
*/
while (*str) {
str += 2;
*cp = '_';
} else {
expansion_len = 1;
}
sleep(5);
exit(0);
}
bp += expansion_len;
}
*bp = 0;
return (result);
}