diff options
author | Peter Somogyi <psomogyi@gamax.hu> | 2007-04-20 14:26:19 +0200 |
---|---|---|
committer | Peter Somogyi <psomogyi@gamax.hu> | 2007-04-20 14:26:19 +0200 |
commit | e5f2e5e5eb56c390c68c1ac79a32fb068510fc41 (patch) | |
tree | 2051f1374b1a9743cbdd3643c84d6ee1d89ea376 /ctdb/lib/util/debug.c | |
parent | c950e5285830eb14f0fced820bbb2ad8927c5421 (diff) | |
download | samba-e5f2e5e5eb56c390c68c1ac79a32fb068510fc41.tar.gz samba-e5f2e5e5eb56c390c68c1ac79a32fb068510fc41.tar.xz samba-e5f2e5e5eb56c390c68c1ac79a32fb068510fc41.zip |
- ctdb/ib minor bugfixes (error case)
- make ctdb capable of alternative connection (like ib) again, solved the fork problem
- do_debug memory overwrite bugfix (occured using ibwrapper_test with wrong address given)
(This used to be ctdb commit da0b84cda26d544f63841dfd770ed7ebad401944)
Diffstat (limited to 'ctdb/lib/util/debug.c')
-rw-r--r-- | ctdb/lib/util/debug.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ctdb/lib/util/debug.c b/ctdb/lib/util/debug.c index a3229015ca..ffe1dcc382 100644 --- a/ctdb/lib/util/debug.c +++ b/ctdb/lib/util/debug.c @@ -22,6 +22,22 @@ #include "system/time.h" #include <unistd.h> +static int vasprintf2(char **ptr, const char *format, va_list ap) +{ + int ret; + va_list tmp_ap; + + va_copy(tmp_ap, ap); + ret = vsnprintf(NULL, 0, format, tmp_ap); + if (ret <= 0) return ret; + + (*ptr) = (char *)malloc(ret+1); + if (!*ptr) return -1; + ret = vsnprintf(*ptr, ret+1, format, ap); + + return ret; +} + void do_debug(const char *format, ...) { struct timeval tm; @@ -29,7 +45,7 @@ void do_debug(const char *format, ...) char *s = NULL; va_start(ap, format); - vasprintf(&s, format, ap); + vasprintf2(&s, format, ap); va_end(ap); gettimeofday(&tm, NULL); |