Make sure we don't clobber the stack when response consists of the empty
authorRichard Sharpe <sharpe@samba.org>
Tue, 16 Mar 2004 06:56:20 +0000 (06:56 +0000)
committerRichard Sharpe <sharpe@samba.org>
Tue, 16 Mar 2004 06:56:20 +0000 (06:56 +0000)
string.
(This used to be commit e522663717f6b6141580f34502ad8686d326f8c8)

source3/nsswitch/winbindd_wins.c

index bc982d00443fb749f5061f595118a235b119da44..a1eef159c0a8d1a13df9d270fb2a494b9302d560 100644 (file)
@@ -201,7 +201,10 @@ enum winbindd_result winbindd_wins_byname(struct winbindd_cli_state *state)
                    }
                    if (i != 0) {
                        /* Clear out the newline character */
-                       response[strlen(response)-1] = ' '; 
+                       /* But only if there is something in there, 
+                          otherwise we clobber something in the stack */
+                       if (strlen(response))
+                               response[strlen(response)-1] = ' '; 
                    }
                    fstrcat(response,addr);
                    fstrcat(response,"\t");