[systemd-commits] src/tty-ask-password-agent.c
Lennart Poettering
lennart at kemper.freedesktop.org
Mon Jul 4 10:01:33 PDT 2011
src/tty-ask-password-agent.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
New commits:
commit 9726f9ff11fa7b94dceed2972cd2453a08b9ee6a
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Jul 4 18:59:54 2011 +0200
password-agent: make sure not to access unallocated memory
Tracked down by Frederic Crozat
diff --git a/src/tty-ask-password-agent.c b/src/tty-ask-password-agent.c
index b620aa6..38442f6 100644
--- a/src/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent.c
@@ -376,12 +376,14 @@ static int parse_password(const char *filename, char **wall) {
release_terminal();
}
- packet_length = 1+strlen(password)+1;
- if (!(packet = new(char, packet_length)))
- r = -ENOMEM;
- else {
- packet[0] = '+';
- strcpy(packet+1, password);
+ if (r >= 0) {
+ packet_length = 1+strlen(password)+1;
+ if (!(packet = new(char, packet_length)))
+ r = -ENOMEM;
+ else {
+ packet[0] = '+';
+ strcpy(packet+1, password);
+ }
}
free(password);
More information about the systemd-commits
mailing list