chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b8590c1
)
password-agent: make sure not to access unallocated memory
author
Lennart Poettering
<lennart@poettering.net>
Mon, 4 Jul 2011 16:59:54 +0000
(18:59 +0200)
committer
Lennart Poettering
<lennart@poettering.net>
Mon, 4 Jul 2011 17:00:48 +0000
(19:00 +0200)
Tracked down by Frederic Crozat
src/tty-ask-password-agent.c
patch
|
blob
|
history
diff --git
a/src/tty-ask-password-agent.c
b/src/tty-ask-password-agent.c
index b620aa6ee3e5dece2d3ef4dd684f959272287f6d..38442f66bda3e61ecd46213f07ef7bf46f77792c 100644
(file)
--- 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);