Updated to version 1.181

Please keep in mind that this is still a development version and might surprise you (not necessarily in a good way).

Do not let me discourage you to build and test this version, although there will be some risks involved such as data corruption or loss of data.
This commit is contained in:
obarthel
2018-09-15 11:56:09 +02:00
parent 806d8089bf
commit 3a06bbdacf
12 changed files with 1070 additions and 689 deletions
+7 -7
View File
@@ -460,7 +460,7 @@ print_smb_data(struct line_buffer * lb,int num_data_bytes_left,const unsigned ch
/* Print the row offset (in bytes) at the start of the
* output line.
*/
SPrintf(format_buffer,"%04lx:",row_offset);
LocalSNPrintf(format_buffer,sizeof(format_buffer),"%04lx:",row_offset);
copy_string_to_line_buffer(lb,format_buffer,5,0);
@@ -489,7 +489,7 @@ print_smb_data(struct line_buffer * lb,int num_data_bytes_left,const unsigned ch
/* Convert this data byte to hexadecimal
* representation.
*/
SPrintf(format_buffer,"%02lx",c);
LocalSNPrintf(format_buffer,sizeof(format_buffer),"%02lx",c);
strcat(dword_buffer,format_buffer);
dword_buffer_len += 2;
@@ -586,7 +586,7 @@ convert_filetime_to_string(const unsigned long * qword)
tm = convert_filetime_to_tm(qword);
SPrintf(string,"%ld-%02ld-%02ldT%02ld:%02ld:%02ldZ",
LocalSNPrintf(string,sizeof(string),"%ld-%02ld-%02ldT%02ld:%02ld:%02ldZ",
tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,
tm->tm_hour,tm->tm_min,tm->tm_sec);
@@ -603,7 +603,7 @@ convert_smb_date_time_to_string(unsigned short smb_date,unsigned short smb_time)
tm = convert_smb_date_time_to_tm(smb_date,smb_time);
SPrintf(string,"%ld-%02ld-%02ldT%02ld:%02ld:%02ldZ",
LocalSNPrintf(string,sizeof(string),"%ld-%02ld-%02ldT%02ld:%02ld:%02ldZ",
tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,
tm->tm_hour,tm->tm_min,tm->tm_sec);
@@ -621,7 +621,7 @@ convert_utime_to_string(unsigned long utime)
tm = gmtime(&when);
SPrintf(string,"%ld-%02ld-%02ldT%02ld:%02ld:%02ldZ",
LocalSNPrintf(string,sizeof(string),"%ld-%02ld-%02ldT%02ld:%02ld:%02ldZ",
tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,
tm->tm_hour,tm->tm_min,tm->tm_sec);
@@ -978,7 +978,7 @@ print_smb_transaction2_subcommand(int command,enum smb_packet_source_t smb_packe
{
char code_string[40];
SPrintf(code_string,"<%02lx%02ld>",unicode_char >> 8,unicode_char & 0xff);
LocalSNPrintf(code_string,sizeof(code_string),"<%02lx%02ld>",unicode_char >> 8,unicode_char & 0xff);
copy_string_to_line_buffer(&lb,code_string,strlen(code_string),output_offset);
output_offset += strlen(code_string);
@@ -2361,7 +2361,7 @@ print_smb_contents(const struct smb_header * header,int command,enum smb_packet_
{
char code_string[40];
SPrintf(code_string,"<%02lx%02ld>",unicode_char >> 8,unicode_char & 0xff);
LocalSNPrintf(code_string,sizeof(code_string),"<%02lx%02ld>",unicode_char >> 8,unicode_char & 0xff);
copy_string_to_line_buffer(&lb,code_string,strlen(code_string),output_offset);
output_offset += strlen(code_string);
+797 -481
View File
File diff suppressed because it is too large Load Diff
+13 -13
View File
@@ -1049,7 +1049,7 @@ smb_request_ok_with_payload (
}
else
{
D(("smb_request() returned %ld bytes\n", result));
LOG(("smb_request() returned %ld bytes\n", result));
/* Return 0 for success, rather than the number of
* bytes received.
@@ -1234,7 +1234,7 @@ smb_proc_open (struct smb_server *server, const char *pathname, int len, int wri
ENTER();
D(("pathname = '%s'", escape_name(pathname)));
LOG(("pathname = '%s'\n", escape_name(pathname)));
/* Because the original code opened every file/directory in
* read/write mode, we emulate the same behaviour. Why this
@@ -2745,7 +2745,7 @@ smb_decode_long_dirent (const struct smb_server *server, const char *p, struct s
/* Skip directory entries whose names we cannot store. */
if(name_len >= (int)finfo->complete_path_size)
{
D(("name length >= %ld (skipping it)", finfo->complete_path_size));
LOG(("name length >= %ld (skipping it)\n", finfo->complete_path_size));
success = FALSE;
break;
@@ -2753,7 +2753,7 @@ smb_decode_long_dirent (const struct smb_server *server, const char *p, struct s
if(name_len == 0)
{
D(("name length == 0 (skipping it)"));
LOG(("name length == 0 (skipping it)\n"));
success = FALSE;
break;
@@ -2779,7 +2779,7 @@ smb_decode_long_dirent (const struct smb_server *server, const char *p, struct s
finfo->len = name_len;
D(("name = '%s', length=%ld, size=%ld",escape_name(finfo->complete_path),name_len,name_size));
LOG(("name = '%s', length=%ld, size=%ld\n",escape_name(finfo->complete_path),name_len,name_size));
#if DEBUG
{
@@ -2879,7 +2879,7 @@ smb_decode_long_dirent (const struct smb_server *server, const char *p, struct s
/* Skip directory entries whose names we cannot store. */
if(name_len >= (int)finfo->complete_path_size)
{
D(("name length >= %ld (skipping it)", finfo->complete_path_size));
LOG(("name length >= %ld (skipping it)\n", finfo->complete_path_size));
success = FALSE;
break;
@@ -2887,7 +2887,7 @@ smb_decode_long_dirent (const struct smb_server *server, const char *p, struct s
if(name_len == 0)
{
D(("name length == 0 (skipping it)"));
LOG(("name length == 0 (skipping it)\n"));
success = FALSE;
break;
@@ -2905,7 +2905,7 @@ smb_decode_long_dirent (const struct smb_server *server, const char *p, struct s
finfo->len = name_len;
D(("name = '%s', length=%ld, size=%ld",escape_name(finfo->complete_path),name_len,name_size));
LOG(("name = '%s', length=%ld, size=%ld\n",escape_name(finfo->complete_path),name_len,name_size));
#if DEBUG
{
@@ -2934,7 +2934,7 @@ smb_decode_long_dirent (const struct smb_server *server, const char *p, struct s
break;
}
D(("entry_length = %ld",(*entry_length_ptr)));
LOG(("entry_length = %ld\n",(*entry_length_ptr)));
RETURN(success);
return(success);
@@ -3192,7 +3192,7 @@ smb_proc_readdir_long (struct smb_server *server, const char *path, int fpos, in
*/
const int grow_size_by = 16;
D(("increasing mask; old value = %ld new value = %ld",mask_buffer_size,len + grow_size_by));
LOG(("increasing mask; old value = %ld new value = %ld\n",mask_buffer_size,len + grow_size_by));
mask_buffer_size = len + grow_size_by;
SHOWVALUE(mask_buffer_size);
@@ -4709,7 +4709,7 @@ smb_proc_reconnect (struct smb_server *server, int * error_ptr)
string_toupper(share_name);
D(("share_name = '%s'", escape_name(share_name)));
LOG(("share_name = '%s'\n", escape_name(share_name)));
if(server->unicode_enabled)
share_name_size = 2 * (share_name_len + 1);
@@ -4814,7 +4814,7 @@ smb_proc_reconnect (struct smb_server *server, int * error_ptr)
/* We need to allocate a larger packet buffer. */
packet_size = max_buffer_size;
D(("packet size updated to %ld bytes\n", packet_size));
LOG(("packet size updated to %ld bytes\n", packet_size));
free (server->transmit_buffer);
@@ -4843,7 +4843,7 @@ smb_proc_reconnect (struct smb_server *server, int * error_ptr)
if(8000 <= server->mount_data.given_max_xmit && server->mount_data.given_max_xmit < (int)max_buffer_size)
{
max_buffer_size = server->mount_data.given_max_xmit;
D(("maximum buffer size limited to %ld bytes\n", max_buffer_size));
LOG(("maximum buffer size limited to %ld bytes\n", max_buffer_size));
}
server->max_buffer_size = max_buffer_size;
+31 -31
View File
@@ -84,39 +84,39 @@ smba_connect (
if(opt_raw_smb)
res->server.raw_smb = TRUE;
D(("use raw SMB = %s",opt_raw_smb ? "yes" : "no"));
LOG(("use raw SMB = %s\n",opt_raw_smb ? "yes" : "no"));
/* Timeout for send/receive operations in seconds. */
res->server.timeout = timeout;
D(("send/receive/connect timeout = %ld seconds%s",timeout,timeout > 0 ? "" : " (= default timeout)"));
LOG(("send/receive/connect timeout = %ld seconds%s\n",timeout,timeout > 0 ? "" : " (= default timeout)"));
/* Enable Unicode support if the server supports it, too. */
res->server.use_unicode = opt_unicode;
D(("use Unicode = %s",opt_unicode ? "yes" : "no"));
LOG(("use Unicode = %s\n",opt_unicode ? "yes" : "no"));
/* Prefer SMB core protocol commands to NT1 commands, if possible. */
res->server.prefer_core_protocol = opt_prefer_core_protocol;
D(("prefer core protocol = %s",opt_prefer_core_protocol ? "yes" : "no"));
LOG(("prefer core protocol = %s\n",opt_prefer_core_protocol ? "yes" : "no"));
/* Path names are case-sensitive. */
res->server.case_sensitive = opt_case_sensitive;
D(("path names are case sensitive = %s",opt_case_sensitive ? "yes" : "no"));
LOG(("path names are case sensitive = %s\n",opt_case_sensitive ? "yes" : "no"));
/* Delay the use of Unicode strings during session setup. */
res->server.session_setup_delay_unicode = opt_session_setup_delay_unicode;
D(("delay use of unicode during session setup = %s",opt_session_setup_delay_unicode ? "yes" : "no"));
LOG(("delay use of unicode during session setup = %s\n",opt_session_setup_delay_unicode ? "yes" : "no"));
/* Enable asynchronous SMB_COM_WRITE_RAW operations? */
res->server.write_behind = opt_write_behind;
D(("use asynchronous SMB_COM_WRITE_RAW operations = %s",opt_write_behind ? "yes" : "no"));
LOG(("use asynchronous SMB_COM_WRITE_RAW operations = %s\n",opt_write_behind ? "yes" : "no"));
D(("cache size = %ld entries", cache_size));
LOG(("cache size = %ld entries\n", cache_size));
if(smba_setup_dircache (res,cache_size,error_ptr) < 0)
{
@@ -126,7 +126,7 @@ smba_connect (
strlcpy(data.workgroup_name,workgroup_name,sizeof(data.workgroup_name));
D(("workgroup name = '%s'",workgroup_name));
LOG(("workgroup name = '%s'\n",workgroup_name));
res->server.abstraction = res;
@@ -140,9 +140,9 @@ smba_connect (
if ((s = strchr (hostname, '.')) != NULL)
(*s) = '\0';
D(("local host name = '%s'",hostname));
LOG(("local host name = '%s'\n",hostname));
D(("server ip address = %s",Inet_NtoA(server_ip_addr.sin_addr.s_addr)));
LOG(("server ip address = %s\n",Inet_NtoA(server_ip_addr.sin_addr.s_addr)));
data.addr = server_ip_addr;
@@ -209,24 +209,24 @@ smba_connect (
strlcpy (data.service, p->service, sizeof(data.service));
D(("service = '%s'",data.service));
LOG(("service = '%s'\n",data.service));
string_toupper (data.service);
strlcpy (data.username, p->username, sizeof(data.username));
strlcpy (data.password, p->password, sizeof(data.password));
D(("user name = '%s'",data.username));
LOG(("user name = '%s'\n",data.username));
data.given_max_xmit = max_transmit;
D(("max transmit = %ld bytes",max_transmit));
LOG(("max transmit = %ld bytes\n",max_transmit));
strlcpy (data.server_name, p->server_name, sizeof(data.server_name));
strlcpy (data.client_name, p->client_name, sizeof(data.client_name));
D(("server name = '%s'",data.server_name));
D(("client name = '%s'",data.client_name));
LOG(("server name = '%s'\n",data.server_name));
LOG(("client name = '%s'\n",data.client_name));
if (data.server_name[0] == '\0')
{
@@ -609,7 +609,7 @@ smba_read (smba_file_t * f, char *data, long len, const QUAD * const offset, int
if (result < 0)
goto out;
D(("read %ld bytes from offset %ld",len,offset));
LOG(("read %ld bytes from offset %ld\n",len,offset));
/* SMB_COM_READ_ANDX supported? */
if (f->server->server.protocol >= PROTOCOL_LANMAN1 && !f->server->server.prefer_core_protocol)
@@ -668,7 +668,7 @@ smba_read (smba_file_t * f, char *data, long len, const QUAD * const offset, int
if(result < count)
{
D(("read returned fewer characters than expected (%ld < %ld)",result,count));
LOG(("read returned fewer characters than expected (%ld < %ld)\n",result,count));
break;
}
}
@@ -699,7 +699,7 @@ smba_read (smba_file_t * f, char *data, long len, const QUAD * const offset, int
result = smb_proc_read_raw (&f->server->server, &f->dirent, &position_quad, n, data, error_ptr);
if(result <= 0)
{
D(("!!! wanted to read %ld bytes, got %ld",n,result));
LOG(("!!! wanted to read %ld bytes, got %ld\n",n,result));
break;
}
@@ -710,7 +710,7 @@ smba_read (smba_file_t * f, char *data, long len, const QUAD * const offset, int
if(result < n)
{
D(("read returned fewer characters than expected (%ld < %ld)",result,n));
LOG(("read returned fewer characters than expected (%ld < %ld)\n",result,n));
break;
}
}
@@ -778,7 +778,7 @@ smba_read (smba_file_t * f, char *data, long len, const QUAD * const offset, int
if(result < count)
{
D(("read returned fewer characters than expected (%ld < %ld)",result,count));
LOG(("read returned fewer characters than expected (%ld < %ld)\n",result,count));
break;
}
}
@@ -1107,11 +1107,11 @@ smba_getattr (smba_file_t * f, smba_stat_t * data, int * error_ptr)
dirent = &f->dirent;
data->is_dir = (dirent->attr & SMB_FILE_ATTRIBUTE_DIRECTORY) != 0;
data->is_read_only = (dirent->attr & SMB_FILE_ATTRIBUTE_READONLY) != 0;
data->is_hidden = (dirent->attr & SMB_FILE_ATTRIBUTE_HIDDEN) != 0;
data->is_system = (dirent->attr & SMB_FILE_ATTRIBUTE_SYSTEM) != 0;
data->is_changed_since_last_archive = (dirent->attr & SMB_FILE_ATTRIBUTE_ARCHIVE) != 0;
data->is_dir = (dirent->attr & SMB_FILE_ATTRIBUTE_DIRECTORY) != 0;
data->is_read_only = (dirent->attr & SMB_FILE_ATTRIBUTE_READONLY) != 0;
data->is_hidden = (dirent->attr & SMB_FILE_ATTRIBUTE_HIDDEN) != 0;
data->is_system = (dirent->attr & SMB_FILE_ATTRIBUTE_SYSTEM) != 0;
data->was_changed_since_last_archive = (dirent->attr & SMB_FILE_ATTRIBUTE_ARCHIVE) != 0;
data->size_low = dirent->size_low;
data->size_high = dirent->size_high;
@@ -1167,7 +1167,7 @@ smba_setattr (smba_file_t * f, const smba_stat_t * st, const QUAD * const size,
else
attrs &= ~SMB_FILE_ATTRIBUTE_READONLY;
if (st->is_changed_since_last_archive)
if (st->was_changed_since_last_archive)
attrs |= SMB_FILE_ATTRIBUTE_ARCHIVE;
else
attrs &= ~SMB_FILE_ATTRIBUTE_ARCHIVE;
@@ -1306,7 +1306,7 @@ smba_readdir (smba_file_t * f, int offs, void *callback_data, smba_callback_t ca
data.is_read_only = (dirent->attr & SMB_FILE_ATTRIBUTE_READONLY) != 0;
data.is_hidden = (dirent->attr & SMB_FILE_ATTRIBUTE_HIDDEN) != 0;
data.is_system = (dirent->attr & SMB_FILE_ATTRIBUTE_SYSTEM) != 0;
data.is_changed_since_last_archive = (dirent->attr & SMB_FILE_ATTRIBUTE_ARCHIVE) != 0;
data.was_changed_since_last_archive = (dirent->attr & SMB_FILE_ATTRIBUTE_ARCHIVE) != 0;
data.size_low = dirent->size_low;
data.size_high = dirent->size_high;
data.atime = dirent->atime;
@@ -1334,7 +1334,7 @@ invalidate_dircache (struct smba_server * server)
ENTER();
if(dircache->cache_for != NULL)
D(("dircache->cache_for->dirent.complete_path = '%s'", escape_name(dircache->cache_for->dirent.complete_path)));
LOG(("dircache->cache_for->dirent.complete_path = '%s'\n", escape_name(dircache->cache_for->dirent.complete_path)));
else
SHOWMSG("-- directory cache is empty --");
@@ -1910,7 +1910,7 @@ smba_start(
*/
if(SendNetBIOSStatusQuery(server_ip_address,server_name,sizeof(server_name),workgroup_name,sizeof(workgroup_name)) == 0 && server_name[0] != '\0')
{
D(("server %s provided its own name '%s', with workgroup '%s'",Inet_NtoA(server_ip_address.sin_addr.s_addr),server_name,workgroup_name));
LOG(("server %s provided its own name '%s', with workgroup '%s'\n",Inet_NtoA(server_ip_address.sin_addr.s_addr),server_name,workgroup_name));
/* No workgroup given? Use what the server told us... */
if(opt_workgroup == NULL && workgroup_name[0] != '\0')
@@ -2035,7 +2035,7 @@ smba_start(
par.username = username;
par.password = password;
D(("server name = '%s', client name = '%s', workgroup name = '%s', user name = '%s'", server_name, client_name, workgroup, username));
LOG(("server name = '%s', client name = '%s', workgroup name = '%s', user name = '%s'\n", server_name, client_name, workgroup, username));
if(smba_connect (
&par,
+1 -1
View File
@@ -67,7 +67,7 @@ typedef struct smba_stat
unsigned is_read_only:1;
unsigned is_hidden:1;
unsigned is_system:1;
unsigned is_changed_since_last_archive:1;
unsigned was_changed_since_last_archive:1;
unsigned long size_low;
unsigned long size_high;
+3 -1
View File
@@ -41,7 +41,9 @@
#define SAME (0)
#define OK (0)
#define CANNOT !
#define NOT !
#define NO !
#define NOTHING ((void)0)
/****************************************************************************/
@@ -146,7 +148,7 @@ extern ULONG get_current_time(void);
extern void seconds_to_tm(time_t seconds,struct tm * tm);
extern void VARARGS68K report_error(const TEXT * fmt,...);
extern void string_toupper(STRPTR s);
extern void VARARGS68K SPrintf(STRPTR buffer, const TEXT * formatString,...);
extern void VARARGS68K LocalSNPrintf(STRPTR buffer, int limit, const TEXT * formatString,...);
extern TEXT * escape_name(const TEXT * name);
extern const char * convert_quad_to_string(const QUAD * const number);
+5 -5
View File
@@ -1,6 +1,6 @@
#define VERSION 1
#define REVISION 177
#define DATE "27.8.2018"
#define VERS "smbfs 1.177"
#define VSTRING "smbfs 1.177 (27.8.2018)\r\n"
#define VERSTAG "\0$VER: smbfs 1.177 (27.8.2018)"
#define REVISION 181
#define DATE "15.9.2018"
#define VERS "smbfs 1.181"
#define VSTRING "smbfs 1.181 (15.9.2018)\r\n"
#define VERSTAG "\0$VER: smbfs 1.181 (15.9.2018)"
+1 -1
View File
@@ -1 +1 @@
177
181
+3 -3
View File
@@ -149,7 +149,7 @@ smb_discard_netbios_frames(struct smb_server *server, int sock_fd, int * error_p
* NetBIOS session response, but for any command
* these message types are invalid.
*/
D(("Invalid session header type 0x%02lx\n", netbios_session_buf[0]));
LOG(("Invalid session header type 0x%02lx\n", netbios_session_buf[0]));
(*error_ptr) = error_invalid_netbios_session;
@@ -165,7 +165,7 @@ smb_discard_netbios_frames(struct smb_server *server, int sock_fd, int * error_p
/* The length in the NetBIOS header is the raw data length (17 bits) */
if (netbios_session_payload_size > server->transmit_buffer_allocation_size)
{
D(("Received length (%ld) > max_xmit (%ld)!", netbios_session_payload_size, server->transmit_buffer_allocation_size));
LOG(("Received length (%ld) > max_xmit (%ld)!\n", netbios_session_payload_size, server->transmit_buffer_allocation_size));
(*error_ptr) = error_message_exceeds_buffer_size;
@@ -176,7 +176,7 @@ smb_discard_netbios_frames(struct smb_server *server, int sock_fd, int * error_p
result = receive_all (sock_fd, server->transmit_buffer, netbios_session_payload_size, error_ptr);
if (result < 0)
{
D(("recv error = %ld", (*error_ptr)));
LOG(("recv error = %ld\n", (*error_ptr)));
goto out;
}
}