Paranoia: clear buffers before returning.
Submitted by: Dmitry V. Levin <ldv@altlinux.org> git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@250 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
parent
0bca19fe3b
commit
1c16675283
|
@ -31,7 +31,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $P4: //depot/projects/openpam/lib/openpam_ttyconv.c#20 $
|
* $P4: //depot/projects/openpam/lib/openpam_ttyconv.c#21 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -68,6 +68,7 @@ prompt(const char *msg)
|
||||||
sigset_t saved_sigset, sigset;
|
sigset_t saved_sigset, sigset;
|
||||||
unsigned int saved_alarm;
|
unsigned int saved_alarm;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
char *retval;
|
||||||
|
|
||||||
sigemptyset(&sigset);
|
sigemptyset(&sigset);
|
||||||
sigaddset(&sigset, SIGINT);
|
sigaddset(&sigset, SIGINT);
|
||||||
|
@ -89,14 +90,18 @@ prompt(const char *msg)
|
||||||
sigaction(SIGALRM, &saved_action, NULL);
|
sigaction(SIGALRM, &saved_action, NULL);
|
||||||
sigprocmask(SIG_SETMASK, &saved_sigset, NULL);
|
sigprocmask(SIG_SETMASK, &saved_sigset, NULL);
|
||||||
alarm(saved_alarm);
|
alarm(saved_alarm);
|
||||||
if (timed_out || ferror(stdin) || feof(stdin))
|
if (timed_out || ferror(stdin) || feof(stdin)) {
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
}
|
||||||
/* trim trailing whitespace */
|
/* trim trailing whitespace */
|
||||||
for (len = strlen(buf); len > 0; --len)
|
for (len = strlen(buf); len > 0; --len)
|
||||||
if (!isspace(buf[len - 1]))
|
if (!isspace(buf[len - 1]))
|
||||||
break;
|
break;
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
return (strdup(buf));
|
retval = strdup(buf);
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
return (retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
@ -179,7 +184,10 @@ openpam_ttyconv(int n,
|
||||||
RETURNC(PAM_SUCCESS);
|
RETURNC(PAM_SUCCESS);
|
||||||
fail:
|
fail:
|
||||||
while (i)
|
while (i)
|
||||||
FREE(resp[--i]);
|
if (resp[--i]->resp) {
|
||||||
|
memset(resp[i]->resp, 0, strlen(resp[i]->resp));
|
||||||
|
FREE(resp[i]->resp);
|
||||||
|
}
|
||||||
FREE(*resp);
|
FREE(*resp);
|
||||||
RETURNC(PAM_CONV_ERR);
|
RETURNC(PAM_CONV_ERR);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue