summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2011-11-19 00:49:52 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2011-11-19 00:49:52 -0800
commit3570de4c260cf45d202e3577d13385d722d043d1 (patch)
treebc6fc5e66ff8ffbe199a10376afaecfdd5a6182c /io.c
parentc6b02069954ef83f8766d6a157b0a95939523d32 (diff)
Replace many malloc(strlen)+strcpy calls with strdup calls
Some used local Malloc wrapper that checked for a NULL return and exited, so had to add matching checks for strdup returning NULL. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'io.c')
-rw-r--r--io.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/io.c b/io.c
index b1de209..2eb9e58 100644
--- a/io.c
+++ b/io.c
@@ -620,15 +620,18 @@ ProcessNewClientConnection (
* the log data struct will go out of scope before we check the
* server security extension or other loggable events)
*/
- client_conn_array[temp_sock_fd]->source =
- Malloc(strlen(inet_ntoa(temp_sockaddr_in.sin_addr)) + 1);
- client_conn_array[temp_sock_fd]->destination =
- Malloc(strlen(inet_ntoa(server_sockaddr_in.sin_addr)) + 1);
-
- (void) strcpy(client_conn_array[temp_sock_fd]->source,
- inet_ntoa(temp_sockaddr_in.sin_addr));
- (void) strcpy(client_conn_array[temp_sock_fd]->destination,
- inet_ntoa(server_sockaddr_in.sin_addr));
+ if ((client_conn_array[temp_sock_fd]->source =
+ strdup(inet_ntoa(temp_sockaddr_in.sin_addr))) == NULL)
+ {
+ (void) fprintf (stderr, "malloc - client source addr\n");
+ return;
+ }
+ if ((client_conn_array[temp_sock_fd]->destination =
+ strdup(inet_ntoa(server_sockaddr_in.sin_addr))) == NULL)
+ {
+ (void) fprintf (stderr, "malloc - client dest addr\n");
+ return;
+ }
/*
* allocate a buffer for the X server connection