diff options
author | Jeremy Allison <jra@samba.org> | 2012-03-28 16:49:30 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2012-03-29 20:48:15 +0200 |
commit | 5df1c115391f2d673d3dd2dfb89146ce77639d41 (patch) | |
tree | 6476e3ef1ad04b57f230f4f4167e04e020bce111 /lib/util/fault.c | |
parent | 762928945d8c18abbce1447fb0e731a4515ffb4c (diff) | |
download | samba-5df1c115391f2d673d3dd2dfb89146ce77639d41.tar.gz |
Start to add truncate checks on all uses of strlcpy(). Reading lwn
has it's uses :-).
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Thu Mar 29 20:48:15 CEST 2012 on sn-devel-104
Diffstat (limited to 'lib/util/fault.c')
-rw-r--r-- | lib/util/fault.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/util/fault.c b/lib/util/fault.c index d0b34e540b4..4f8e8db5ca7 100644 --- a/lib/util/fault.c +++ b/lib/util/fault.c @@ -116,8 +116,6 @@ _PUBLIC_ const char *panic_action = NULL; */ static void smb_panic_default(const char *why) { - int result; - #if defined(HAVE_PRCTL) && defined(PR_SET_PTRACER) /* * Make sure all children can attach a debugger. @@ -126,20 +124,22 @@ static void smb_panic_default(const char *why) #endif if (panic_action && *panic_action) { - char pidstr[20]; char cmdstring[200]; - strlcpy(cmdstring, panic_action, sizeof(cmdstring)); - snprintf(pidstr, sizeof(pidstr), "%d", (int) getpid()); - all_string_sub(cmdstring, "%d", pidstr, sizeof(cmdstring)); - DEBUG(0, ("smb_panic(): calling panic action [%s]\n", cmdstring)); - result = system(cmdstring); - - if (result == -1) - DEBUG(0, ("smb_panic(): fork failed in panic action: %s\n", - strerror(errno))); - else - DEBUG(0, ("smb_panic(): action returned status %d\n", - WEXITSTATUS(result))); + if (strlcpy(cmdstring, panic_action, sizeof(cmdstring)) < sizeof(cmdstring)) { + int result; + char pidstr[20]; + snprintf(pidstr, sizeof(pidstr), "%d", (int) getpid()); + all_string_sub(cmdstring, "%d", pidstr, sizeof(cmdstring)); + DEBUG(0, ("smb_panic(): calling panic action [%s]\n", cmdstring)); + result = system(cmdstring); + + if (result == -1) + DEBUG(0, ("smb_panic(): fork failed in panic action: %s\n", + strerror(errno))); + else + DEBUG(0, ("smb_panic(): action returned status %d\n", + WEXITSTATUS(result))); + } } DEBUG(0,("PANIC: %s\n", why)); |