diff options
author | Karel Zak <kzak@redhat.com> | 2014-07-25 15:38:31 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-07-26 15:08:41 -0400 |
commit | 7de80bfe2e61d5818601ccfddbadad3b7703ed70 (patch) | |
tree | b8b90c03198f2f2125d13e175b2223e6239894f0 /src/tty-ask-password-agent | |
parent | 6d314eca15f6cbda38d82774b210f784d3d4f52a (diff) |
Always check asprintf return code
There is a small number of the places in sources where we don't check
asprintf() return code and assume that after error the function
returns NULL pointer via the first argument. That's wrong, after
error the content of pointer is undefined.
Diffstat (limited to 'src/tty-ask-password-agent')
-rw-r--r-- | src/tty-ask-password-agent/tty-ask-password-agent.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c index a7fce518a5..2c540ba170 100644 --- a/src/tty-ask-password-agent/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c @@ -102,8 +102,9 @@ static int ask_password_plymouth( if (accept_cached) { packet = strdup("c"); n = 1; - } else - asprintf(&packet, "*\002%c%s%n", (int) (strlen(message) + 1), message, &n); + } else if (asprintf(&packet, "*\002%c%s%n", (int) (strlen(message) + 1), + message, &n) < 0) + packet = NULL; if (!packet) { r = -ENOMEM; |