Merge branch 'ctdb-merge' into v3-2-test
[nivanova/samba-autobuild/.git] / examples / libsmbclient / smbwrapper / smbw_dir.c
index f3ec03e5a8583ceae53dc97baad0f3fd795f9343..6e473bf0a33591456fe047ac4b1df519df78021e 100644 (file)
@@ -7,7 +7,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "smbw.h"
+#include "bsd-strlfunc.h"
 
 /***************************************************** 
 determine if a directory handle is a smb one
@@ -70,12 +70,12 @@ int smbw_getdents(unsigned int fd_smbw,
                dirent_external->d_reclen = sizeof(struct SMBW_dirent);
                 dirent_external->d_type = dirent_internal->smbc_type;
 
-                strncpy(dirent_external->d_name,
-                        dirent_internal->name,
-                        sizeof(dirent_external->d_name) - 1);
-                strncpy(dirent_external->d_comment,
-                        dirent_internal->comment,
-                        sizeof(dirent_external->d_comment) - 1);
+                smbw_strlcpy(dirent_external->d_name,
+                             dirent_internal->name,
+                             sizeof(dirent_external->d_name) - 1);
+                smbw_strlcpy(dirent_external->d_comment,
+                             dirent_internal->comment,
+                             sizeof(dirent_external->d_comment) - 1);
        }
 
        return(count - remaining);
@@ -128,7 +128,7 @@ int smbw_chdir(const char *name)
             }
         }
 
-        strncpy(smbw_cwd, path, PATH_MAX);
+        smbw_strlcpy(smbw_cwd, path, PATH_MAX);
 
        /* we don't want the old directory to be busy */
        (* smbw_libc.chdir)("/");
@@ -196,7 +196,7 @@ char *smbw_getcwd(char *buf, size_t size)
                 }
         }
 
-        strncpy(buf, smbw_cwd, size);
+        smbw_strlcpy(buf, smbw_cwd, size);
         buf[size-1] = '\0';
        return buf;
 }
@@ -278,12 +278,12 @@ struct SMBW_dirent *smbw_readdir(DIR *dirp)
         dirent_external.d_off = smbc_telldir(fd_client);
         dirent_external.d_reclen = sizeof(struct SMBW_dirent);
         dirent_external.d_type = dirent_internal->smbc_type;
-        strncpy(dirent_external.d_name,
-                dirent_internal->name,
-                sizeof(dirent_external.d_name) - 1);
-        strncpy(dirent_external.d_comment,
-                dirent_internal->comment,
-                sizeof(dirent_external.d_comment) - 1);
+        smbw_strlcpy(dirent_external.d_name,
+                     dirent_internal->name,
+                     sizeof(dirent_external.d_name) - 1);
+        smbw_strlcpy(dirent_external.d_comment,
+                     dirent_internal->comment,
+                     sizeof(dirent_external.d_comment) - 1);
 
        return &dirent_external;
 }