summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-07-04 18:59:54 +0200
committerLennart Poettering <lennart@poettering.net>2011-07-04 19:00:48 +0200
commit9726f9ff11fa7b94dceed2972cd2453a08b9ee6a (patch)
tree1d35e78b99e457afdb812dc9f8989dd458b209ee /src
parentb8590c197deceab623d37dbb95e30eec9cf47d14 (diff)
password-agent: make sure not to access unallocated memory
Tracked down by Frederic Crozat
Diffstat (limited to 'src')
-rw-r--r--src/tty-ask-password-agent.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/tty-ask-password-agent.c b/src/tty-ask-password-agent.c
index b620aa6ee3..38442f66bd 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);