Index: SAMBA_3_0/source/libsmb/libsmbclient.c =================================================================== --- SAMBA_3_0/source/libsmb/libsmbclient.c (revision 23631) +++ SAMBA_3_0/source/libsmb/libsmbclient.c (working copy) @@ -3459,11 +3459,14 @@ smbc_telldir_ctx(SMBCCTX *context, } + if (!dir->dir_next) { + return -1; + } + /* * We return the pointer here as the offset */ - ret_val = (off_t)(long)dir->dir_next; - return ret_val; + return (off_t)(long)dir->dir_next->dirent; } @@ -3535,6 +3538,13 @@ smbc_lseekdir_ctx(SMBCCTX *context, } + if (offset == -1) { /* Seek to the ending of the list */ + + dir->dir_next = NULL; + return 0; + + } + /* Now, run down the list and make sure that the entry is OK */ /* This may need to be changed if we change the format of the list */