From: Marco van Wieringen Date: Thu, 2 Apr 2009 08:24:40 +0000 (+0000) Subject: Fixed problem in xattr and acl code trying to send empty acl or xattr streams. X-Git-Tag: Release-7.0.0~3178 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4804bd401dd4653048ec7f17b6f5005b416e2878;p=bacula%2Fbacula Fixed problem in xattr and acl code trying to send empty acl or xattr streams. Fix for bug #1261 where we send out a null stream when a file only an acl and xattr support is also turned on. Added some warnings to configure when using libtool and static in one configure. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8677 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index a3c703cd80..c8403c39a1 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -567,6 +567,10 @@ AC_ARG_ENABLE(static-tools, AC_HELP_STRING([--enable-static-tools], [enable static tape tools @<:@default=no@:>@]), [ if test x$enableval = xyes; then + if test x$use_libtool = xyes; then + echo "Libtool is enabled, not compatible with static tools, please rerun configure with --disable-libtool" + exit 1 + fi support_static_tools=yes fi ] @@ -585,6 +589,10 @@ AC_ARG_ENABLE(static-fd, AC_HELP_STRING([--enable-static-fd], [enable static File daemon @<:@default=no@:>@]), [ if test x$enableval = xyes; then + if test x$use_libtool = xyes; then + echo "Libtool is enabled, not compatible with static tools, please rerun configure with --disable-libtool" + exit 1 + fi support_static_fd=yes fi ] @@ -603,6 +611,10 @@ AC_ARG_ENABLE(static-sd, AC_HELP_STRING([--enable-static-sd], [enable static Storage daemon @<:@default=no@:>@]), [ if test x$enableval = xyes; then + if test x$use_libtool = xyes; then + echo "Libtool is enabled, not compatible with static tools, please rerun configure with --disable-libtool" + exit 1 + fi support_static_sd=yes fi ] @@ -621,6 +633,10 @@ AC_ARG_ENABLE(static-dir, AC_HELP_STRING([--enable-static-dir], [enable static Director @<:@default=no@:>@]), [ if test x$enableval = xyes; then + if test x$use_libtool = xyes; then + echo "Libtool is enabled, not compatible with static tools, please rerun configure with --disable-libtool" + exit 1 + fi support_static_dir=yes fi ] @@ -639,6 +655,10 @@ AC_ARG_ENABLE(static-cons, AC_HELP_STRING([--enable-static-cons], [enable static Console @<:@default=no@:>@]), [ if test x$enableval = xyes; then + if test x$use_libtool = xyes; then + echo "Libtool is enabled, not compatible with static tools, please rerun configure with --disable-libtool" + exit 1 + fi support_static_cons=yes fi ] diff --git a/bacula/configure b/bacula/configure index 38ff0f5363..5c576f1266 100755 --- a/bacula/configure +++ b/bacula/configure @@ -24267,6 +24267,10 @@ fi if test "${enable_static_tools+set}" = set; then enableval=$enable_static_tools; if test x$enableval = xyes; then + if test x$use_libtool = xyes; then + echo "Libtool is enabled, not compatible with static tools, please rerun configure with --disable-libtool" + exit 1 + fi support_static_tools=yes fi @@ -24284,6 +24288,10 @@ fi if test "${enable_static_fd+set}" = set; then enableval=$enable_static_fd; if test x$enableval = xyes; then + if test x$use_libtool = xyes; then + echo "Libtool is enabled, not compatible with static tools, please rerun configure with --disable-libtool" + exit 1 + fi support_static_fd=yes fi @@ -24301,6 +24309,10 @@ fi if test "${enable_static_sd+set}" = set; then enableval=$enable_static_sd; if test x$enableval = xyes; then + if test x$use_libtool = xyes; then + echo "Libtool is enabled, not compatible with static tools, please rerun configure with --disable-libtool" + exit 1 + fi support_static_sd=yes fi @@ -24318,6 +24330,10 @@ fi if test "${enable_static_dir+set}" = set; then enableval=$enable_static_dir; if test x$enableval = xyes; then + if test x$use_libtool = xyes; then + echo "Libtool is enabled, not compatible with static tools, please rerun configure with --disable-libtool" + exit 1 + fi support_static_dir=yes fi @@ -24335,6 +24351,10 @@ fi if test "${enable_static_cons+set}" = set; then enableval=$enable_static_cons; if test x$enableval = xyes; then + if test x$use_libtool = xyes; then + echo "Libtool is enabled, not compatible with static tools, please rerun configure with --disable-libtool" + exit 1 + fi support_static_cons=yes fi diff --git a/bacula/src/filed/acl.c b/bacula/src/filed/acl.c index 533c24320e..607c23d1e5 100644 --- a/bacula/src/filed/acl.c +++ b/bacula/src/filed/acl.c @@ -102,6 +102,12 @@ static bool send_acl_stream(JCR *jcr, int stream) return true; #endif + /* + * Sanity check + */ + if (jcr->acl_data_len <= 0) + return true; + /* * Send header */ diff --git a/bacula/src/filed/xattr.c b/bacula/src/filed/xattr.c index 88e33a5a76..44e3f4f60b 100644 --- a/bacula/src/filed/xattr.c +++ b/bacula/src/filed/xattr.c @@ -84,6 +84,12 @@ static bool send_xattr_stream(JCR *jcr, int stream) return true; #endif + /* + * Sanity check + */ + if (jcr->xattr_data_len <= 0) + return true; + /* * Send header */ @@ -242,7 +248,8 @@ static uint32_t serialize_xattr_stream(JCR *jcr, uint32_t expected_serialize_len static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream) { - int count = 0; + bool retval = true; + int count; int32_t xattr_list_len, xattr_value_len; uint32_t expected_serialize_len = 0; @@ -259,6 +266,7 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream) jcr->last_fname, be.bstrerror()); Dmsg2(100, "llistxattr error file=%s ERR=%s\n", jcr->last_fname, be.bstrerror()); + return false; } else if (xattr_list_len == 0) { return true; @@ -286,6 +294,7 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream) jcr->last_fname, be.bstrerror()); free(xattr_list); + return false; } xattr_list[xattr_list_len] = '\0'; @@ -293,6 +302,7 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream) /* * Count the number of extended attributes on a file. */ + count = 0; bp = xattr_list; while ((bp - xattr_list) + 1 < xattr_list_len) { count++; @@ -315,6 +325,7 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream) * Walk the list of extended attributes names and retrieve the data. * We already count the bytes needed for serializing the stream later on. */ + count = 0; current_xattr = xattr_value_list; bp = xattr_list; while ((bp - xattr_list) + 1 < xattr_list_len) { @@ -404,29 +415,34 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream) /* * Next attribute. */ + count++; current_xattr++; bp = strchr(bp, '\0') + 1; } - /* - * Serialize the datastream. - */ - if (serialize_xattr_stream(jcr, expected_serialize_len, xattr_value_list) < expected_serialize_len) { - Jmsg1(jcr, M_ERROR, 0, _("Failed to serialize extended attributes on file \"%s\"\n"), - jcr->last_fname); - Dmsg1(100, "Failed to serialize extended attributes on file \"%s\"\n", - jcr->last_fname); + if (count != 0) { + /* + * Serialize the datastream. + */ + if (serialize_xattr_stream(jcr, expected_serialize_len, xattr_value_list) < expected_serialize_len) { + Jmsg1(jcr, M_ERROR, 0, _("Failed to serialize extended attributes on file \"%s\"\n"), + jcr->last_fname); + Dmsg1(100, "Failed to serialize extended attributes on file \"%s\"\n", + jcr->last_fname); + + goto bail_out; + } - goto bail_out; + /* + * Send the datastream to the SD. + */ + retval = send_xattr_stream(jcr, stream); } xattr_drop_internal_table(xattr_value_list); free(xattr_list); - /* - * Send the datastream to the SD. - */ - return send_xattr_stream(jcr, stream); + return retval; bail_out: xattr_drop_internal_table(xattr_value_list); diff --git a/bacula/technotes b/bacula/technotes index 6ec4355a9f..c2d31b9747 100644 --- a/bacula/technotes +++ b/bacula/technotes @@ -1,6 +1,13 @@ Technical notes for current SVN General: +02Apr09 +mvw Fixed problem in xattr and acl code trying to send empty acl or xattr + streams. +mvw Fix for bug #1261 where we send out a null stream when a file only an + acl and xattr support is also turned on. +mvw Added some warnings to configure when using libtool and static in + one configure. 30Mar09 ebl Fix small memory leak in fileregexp bsr code 29Mar09