diff options
author | Ted Gould <ted@gould.cx> | 2012-08-30 11:14:46 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2012-08-30 11:14:46 -0500 |
commit | d40d11a475fa08d52dc8a66f34ca2ce28ab39b7e (patch) | |
tree | 7a1e67cf8159f98b7f4dc636c5d7d6b72fd41224 | |
parent | a2ece3e4d7694e940e0cca31d663233cf623272b (diff) | |
download | libpam-freerdp2-d40d11a475fa08d52dc8a66f34ca2ce28ab39b7e.tar.gz libpam-freerdp2-d40d11a475fa08d52dc8a66f34ca2ce28ab39b7e.tar.bz2 libpam-freerdp2-d40d11a475fa08d52dc8a66f34ca2ce28ab39b7e.zip |
Checking the return for mlock and snprintf
-rw-r--r-- | src/pam-freerdp.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/pam-freerdp.c b/src/pam-freerdp.c index 33105d4..5696bbd 100644 --- a/src/pam-freerdp.c +++ b/src/pam-freerdp.c @@ -264,6 +264,7 @@ session_socket_handler (struct passwd * pwdent, const char * ruser, const char * /* Our buffer */ char * buffer = NULL; int buffer_len = 0; + int buffer_fill = 0; /* Track write out */ int writedata = 0; @@ -294,8 +295,18 @@ session_socket_handler (struct passwd * pwdent, const char * ruser, const char * } /* Lock the buffer before writing */ - mlock(buffer, buffer_len); - snprintf(buffer, buffer_len, "%s %s %s %s", ruser, password, rdomain, rhost); + if (mlock(buffer, buffer_len) != 0) { + /* We can't lock, we go home */ + goto cleanup; + } + + buffer_fill = snprintf(buffer, buffer_len, "%s %s %s %s", ruser, password, rdomain, rhost); + if (buffer_fill > buffer_len) { + /* This really shouldn't happen, but if for some reason we have an + difference between they way that the lengths are calculated we want + to catch that. */ + goto cleanup; + } /* Make our socket and bind it */ socketfd = socket(AF_UNIX, SOCK_STREAM, 0); |