[PATCH] smb.c: fix gcc warnings (asprintf)

Alexey Tourbin <[email protected]>
Newsgroups gmane.comp.web.links
Message-ID <[email protected]>
---
 src/protocol/smb/smb.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/protocol/smb/smb.c b/src/protocol/smb/smb.c
index 62550e3..a7cc0dc 100644
--- a/src/protocol/smb/smb.c
+++ b/src/protocol/smb/smb.c
@@ -627,8 +627,12 @@ smb_protocol_handler(struct connection *conn)
 
 		if (*share) {
 			/* Construct service path. */
-			asprintf((char **) &v[n++], "//%.*s/%s",
+			int rv = asprintf((char **) &v[n++], "//%.*s/%s",
 				 uri->hostlen, uri->host, share);
+			if (rv < 1) {
+				perror("asprintf");
+				_exit(1);
+			}
 
 			/* Add password if any. */
 			if (uri->passwordlen && !uri->userlen) {
@@ -658,9 +662,13 @@ smb_protocol_handler(struct connection *conn)
 				v[n++] = memacpy(uri->user, uri->userlen);
 			} else {
 				/* With password. */
-				asprintf((char **) &v[n++], "%.*s%%%.*s",
+				int rv = asprintf((char **) &v[n++], "%.*s%%%.*s",
 					 uri->userlen, uri->user,
 					 uri->passwordlen, uri->password);
+				if (rv < 1) {
+					perror("asprintf");
+					_exit(1);
+				}
 			}
 		}
 
-- 
1.5.0.1.GIT
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.