commit b520befe6f51644d20434add9864d7a2fa30aa2e
authorSATOH Fumiyasu <fumiyas@osstech.jp>
Tue, 16 Dec 2008 15:54:30 +0000 (00:54 +0900)
committerDerrell Lipman <derrell.lipman@unwireduniverse.com>
Tue, 16 Dec 2008 17:20:40 +0000 (12:20 -0500)
Author: SATOH Fumiyasu <fumiyas@osstech.co.jp>
Date:   Wed Dec 17 00:42:25 2008 +0900

    libsmbclient: Fix SIGBUS on non-x86 CPUs

    We must align the struct smbc_dirent in the struct
    SMBC_internal_data because the struct smbc_dirent
    has numeric values that require alignment.

Signed-off-by: Derrell Lipman <derrell.lipman@unwireduniverse.com>
source3/include/libsmb_internal.h
source3/libsmb/libsmb_dir.c

index 3b909d13b95e25744434493464b55220fb403374..b4881169396fa7e8aed3558ba834e073eab5ab96 100644 (file)
@@ -113,18 +113,19 @@ struct SMBC_internal_data {
        /* True when this handle is initialized */
        bool                                    initialized;
 
        /* True when this handle is initialized */
        bool                                    initialized;
 
-        /* dirent pointer location
-         *
+        /* dirent pointer location */
+       struct smbc_dirent                      dirent;
+       /*
          * Leave room for any urlencoded filename and the comment field.
          *
          * Leave room for any urlencoded filename and the comment field.
          *
-         * We really should use sizeof(struct smbc_dirent) plus (NAME_MAX * 3)
-         * plus whatever the max length of a comment is, plus a couple of null
-         * terminators (one after the filename, one after the comment).
+        * We use (NAME_MAX * 3) plus whatever the max length of a comment is,
+        * plus a couple of null terminators (one after the filename,
+        * one after the comment).
          *
          * According to <linux/limits.h>, NAME_MAX is 255.  Is it longer
          * anyplace else?
          */
          *
          * According to <linux/limits.h>, NAME_MAX is 255.  Is it longer
          * anyplace else?
          */
-       char                                    dirent[1024];
+       char                                    _dirent_name[1024];
 
        /*
          * server connection list
 
        /*
          * server connection list
index d12e7487f6325cc85faaccfbc71a65a8b5b73390..770014b6f62350632a16fef274bdf37277ea4572 100644 (file)
@@ -976,9 +976,8 @@ SMBC_readdir_ctx(SMBCCTX *context,
 
         }
 
 
         }
 
-        dirp = (struct smbc_dirent *)context->internal->dirent;
-        maxlen = (sizeof(context->internal->dirent) -
-                  sizeof(struct smbc_dirent));
+        dirp = &context->internal->dirent;
+        maxlen = sizeof(context->internal->_dirent_name);
 
         smbc_readdir_internal(context, dirp, dirent, maxlen);
 
 
         smbc_readdir_internal(context, dirp, dirent, maxlen);
 
@@ -1049,9 +1048,8 @@ SMBC_getdents_ctx(SMBCCTX *context,
                }
 
                 /* Do urlencoding of next entry, if so selected */
                }
 
                 /* Do urlencoding of next entry, if so selected */
-                dirent = (struct smbc_dirent *)context->internal->dirent;
-                maxlen = (sizeof(context->internal->dirent) -
-                          sizeof(struct smbc_dirent));
+                dirent = &context->internal->dirent;
+                maxlen = sizeof(context->internal->_dirent_name);
                 smbc_readdir_internal(context, dirent,
                                       dirlist->dirent, maxlen);
 
                 smbc_readdir_internal(context, dirent,
                                       dirlist->dirent, maxlen);