version 1.1.1.1, 2012/02/21 16:23:02
|
version 1.1.1.4, 2013/10/14 07:56:35
|
Line 1
|
Line 1
|
/* |
/* |
* Copyright (c) 1999-2005, 2007-2010 Todd C. Miller <Todd.Miller@courtesan.com> | * Copyright (c) 1999-2005, 2007-2012 Todd C. Miller <Todd.Miller@courtesan.com> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
Line 21
|
Line 21
|
#include <config.h> |
#include <config.h> |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/param.h> |
|
#include <stdio.h> |
#include <stdio.h> |
#ifdef STDC_HEADERS |
#ifdef STDC_HEADERS |
# include <stdlib.h> |
# include <stdlib.h> |
Line 47
|
Line 46
|
|
|
#include "sudo.h" |
#include "sudo.h" |
#include "sudo_plugin.h" |
#include "sudo_plugin.h" |
|
#include "sudo_plugin_int.h" |
|
|
extern int tgetpass_flags; /* XXX */ |
extern int tgetpass_flags; /* XXX */ |
|
|
Line 81 sudo_conversation(int num_msgs, const struct sudo_conv
|
Line 81 sudo_conversation(int num_msgs, const struct sudo_conv
|
if (pass == NULL) |
if (pass == NULL) |
goto err; |
goto err; |
repl->reply = estrdup(pass); |
repl->reply = estrdup(pass); |
zero_bytes(pass, strlen(pass)); | memset_s(pass, SUDO_CONV_REPL_MAX, 0, strlen(pass)); |
break; |
break; |
case SUDO_CONV_INFO_MSG: |
case SUDO_CONV_INFO_MSG: |
if (msg->msg) |
if (msg->msg) |
Line 91 sudo_conversation(int num_msgs, const struct sudo_conv
|
Line 91 sudo_conversation(int num_msgs, const struct sudo_conv
|
if (msg->msg) |
if (msg->msg) |
(void) fputs(msg->msg, stderr); |
(void) fputs(msg->msg, stderr); |
break; |
break; |
|
case SUDO_CONV_DEBUG_MSG: |
|
if (msg->msg) |
|
sudo_debug_write(msg->msg, strlen(msg->msg), 0); |
|
break; |
default: |
default: |
goto err; |
goto err; |
} |
} |
Line 103 err:
|
Line 107 err:
|
do { |
do { |
repl = &replies[n]; |
repl = &replies[n]; |
if (repl->reply != NULL) { |
if (repl->reply != NULL) { |
zero_bytes(repl->reply, strlen(repl->reply)); | memset_s(repl->reply, SUDO_CONV_REPL_MAX, 0, strlen(repl->reply)); |
free(repl->reply); |
free(repl->reply); |
repl->reply = NULL; |
repl->reply = NULL; |
} |
} |
} while (n--); |
} while (n--); |
|
|
return -1; |
return -1; |
} |
|
|
|
int |
|
_sudo_printf(int msg_type, const char *fmt, ...) |
|
{ |
|
va_list ap; |
|
FILE *fp; |
|
int len; |
|
|
|
switch (msg_type) { |
|
case SUDO_CONV_INFO_MSG: |
|
fp = stdout; |
|
break; |
|
case SUDO_CONV_ERROR_MSG: |
|
fp = stderr; |
|
break; |
|
default: |
|
errno = EINVAL; |
|
return -1; |
|
} |
|
|
|
va_start(ap, fmt); |
|
len = vfprintf(fp, fmt, ap); |
|
va_end(ap); |
|
|
|
return len; |
|
} |
} |