diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-04-13 21:26:30 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-04-13 21:26:30 +0200 |
commit | d55f4f3f92f56f76bdd06192d6a2ef3ee9fe4772 (patch) | |
tree | 683467af7c400cb0397edab27643ce79695898a5 /src/tty-ask-password-agent.c | |
parent | 8254a475893e746eb667c0666a69a871d7fc4732 (diff) |
ask-password: always send final NUL char
Diffstat (limited to 'src/tty-ask-password-agent.c')
-rw-r--r-- | src/tty-ask-password-agent.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/tty-ask-password-agent.c b/src/tty-ask-password-agent.c index dcf4b332b3..a414cba374 100644 --- a/src/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent.c @@ -369,10 +369,15 @@ static int parse_password(const char *filename, char **wall) { release_terminal(); } - asprintf(&packet, "+%s", password); - free(password); + packet_length = 1+strlen(password)+1; + if (!(packet = new(char, packet_length))) + r = -ENOMEM; + else { + packet[0] = '+'; + strcpy(packet+1, password); + } - packet_length = strlen(packet); + free(password); } if (r == -ETIME || r == -ENOENT) { @@ -382,17 +387,10 @@ static int parse_password(const char *filename, char **wall) { } if (r < 0) { - log_error("Failed to query password: %s", strerror(-r)); goto finish; } - if (!packet) { - log_error("Out of memory"); - r = -ENOMEM; - goto finish; - } - if ((socket_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) { log_error("socket(): %m"); r = -errno; |