aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-08-30 11:14:46 -0500
committerTed Gould <ted@gould.cx>2012-08-30 11:14:46 -0500
commit55e28977cad16a59abecbe5857fbebfefab4f811 (patch)
tree7a1e67cf8159f98b7f4dc636c5d7d6b72fd41224
parenta17c0a60a2e3f036cf54013f0402c18a5f0768cf (diff)
downloadlibpam-x2go-55e28977cad16a59abecbe5857fbebfefab4f811.tar.gz
libpam-x2go-55e28977cad16a59abecbe5857fbebfefab4f811.tar.bz2
libpam-x2go-55e28977cad16a59abecbe5857fbebfefab4f811.zip
Checking the return for mlock and snprintf
-rw-r--r--src/pam-freerdp.c15
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);