git.samba.org
/
ira
/
wip.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
s3-includes: only include system/filesys.h when needed.
[ira/wip.git]
/
source3
/
torture
/
utable.c
diff --git
a/source3/torture/utable.c
b/source3/torture/utable.c
index 720614cea37a51b6fc1b91f0123a9cb43e904818..3ddb4688341f243cf5125962720fbd6b382c0f70 100644
(file)
--- a/
source3/torture/utable.c
+++ b/
source3/torture/utable.c
@@
-5,7
+5,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
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,
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@
-14,19
+14,20
@@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
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/>.
*/
*/
-#define NO_SYSLOG
-
#include "includes.h"
#include "includes.h"
+#include "system/filesys.h"
+#include "torture/proto.h"
+#include "../libcli/security/security.h"
+#include "libsmb/clirap.h"
-
BOOL
torture_utable(int dummy)
+
bool
torture_utable(int dummy)
{
{
- st
atic struct cli_state
cli;
+ st
ruct cli_state *
cli;
fstring fname, alt_name;
fstring fname, alt_name;
-
in
t fnum;
+
uint16_
t fnum;
smb_ucs2_t c2;
int c, len, fd;
int chars_allowed=0, alt_allowed=0;
smb_ucs2_t c2;
int c, len, fd;
int chars_allowed=0, alt_allowed=0;
@@
-34,14
+35,14
@@
BOOL torture_utable(int dummy)
printf("starting utable\n");
printf("starting utable\n");
- if (!torture_open_connection(&cli)) {
+ if (!torture_open_connection(&cli
, 0
)) {
return False;
}
memset(valid, 0, sizeof(valid));
return False;
}
memset(valid, 0, sizeof(valid));
- cli_mkdir(
&
cli, "\\utable");
- cli_unlink(
&cli, "\\utable\\*"
);
+ cli_mkdir(cli, "\\utable");
+ cli_unlink(
cli, "\\utable\\*", aSYSTEM | aHIDDEN
);
for (c=1; c < 0x10000; c++) {
char *p;
for (c=1; c < 0x10000; c++) {
char *p;
@@
-49,19
+50,20
@@
BOOL torture_utable(int dummy)
SSVAL(&c2, 0, c);
fstrcpy(fname, "\\utable\\x");
p = fname+strlen(fname);
SSVAL(&c2, 0, c);
fstrcpy(fname, "\\utable\\x");
p = fname+strlen(fname);
- len = convert_string(CH_U
CS2
, CH_UNIX,
+ len = convert_string(CH_U
TF16LE
, CH_UNIX,
&c2, 2,
p, sizeof(fname)-strlen(fname));
p[len] = 0;
fstrcat(fname,"_a_long_extension");
&c2, 2,
p, sizeof(fname)-strlen(fname));
p[len] = 0;
fstrcat(fname,"_a_long_extension");
- fnum = cli_open(&cli, fname, O_RDWR | O_CREAT | O_TRUNC,
- DENY_NONE);
- if (fnum == -1) continue;
+ if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC,
+ DENY_NONE, &fnum))) {
+ continue;
+ }
chars_allowed++;
chars_allowed++;
- cli_qpathinfo_alt_name(
&
cli, fname, alt_name);
+ cli_qpathinfo_alt_name(cli, fname, alt_name);
if (strncmp(alt_name, "X_A_L", 5) != 0) {
alt_allowed++;
if (strncmp(alt_name, "X_A_L", 5) != 0) {
alt_allowed++;
@@
-69,8
+71,8
@@
BOOL torture_utable(int dummy)
d_printf("fname=[%s] alt_name=[%s]\n", fname, alt_name);
}
d_printf("fname=[%s] alt_name=[%s]\n", fname, alt_name);
}
- cli_close(
&
cli, fnum);
- cli_unlink(
&cli, fname
);
+ cli_close(cli, fnum);
+ cli_unlink(
cli, fname, aSYSTEM | aHIDDEN
);
if (c % 100 == 0) {
printf("%d (%d/%d)\r", c, chars_allowed, alt_allowed);
if (c % 100 == 0) {
printf("%d (%d/%d)\r", c, chars_allowed, alt_allowed);
@@
-78,7
+80,7
@@
BOOL torture_utable(int dummy)
}
printf("%d (%d/%d)\n", c, chars_allowed, alt_allowed);
}
printf("%d (%d/%d)\n", c, chars_allowed, alt_allowed);
- cli_rmdir(
&
cli, "\\utable");
+ cli_rmdir(cli, "\\utable");
d_printf("%d chars allowed %d alt chars allowed\n", chars_allowed, alt_allowed);
d_printf("%d chars allowed %d alt chars allowed\n", chars_allowed, alt_allowed);
@@
-87,7
+89,11
@@
BOOL torture_utable(int dummy)
d_printf("Failed to create valid.dat - %s", strerror(errno));
return False;
}
d_printf("Failed to create valid.dat - %s", strerror(errno));
return False;
}
- write(fd, valid, 0x10000);
+ if (write(fd, valid, 0x10000) != 0x10000) {
+ d_printf("Failed to create valid.dat - %s", strerror(errno));
+ close(fd);
+ return false;
+ }
close(fd);
d_printf("wrote valid.dat\n");
close(fd);
d_printf("wrote valid.dat\n");
@@
-106,65
+112,73
@@
static char *form_name(int c)
p = fname+strlen(fname);
SSVAL(&c2, 0, c);
p = fname+strlen(fname);
SSVAL(&c2, 0, c);
- len = convert_string(CH_U
CS2
, CH_UNIX,
+ len = convert_string(CH_U
TF16LE
, CH_UNIX,
&c2, 2,
p, sizeof(fname)-strlen(fname));
p[len] = 0;
return fname;
}
&c2, 2,
p, sizeof(fname)-strlen(fname));
p[len] = 0;
return fname;
}
-
BOOL
torture_casetable(int dummy)
+
bool
torture_casetable(int dummy)
{
{
- static struct cli_state cli;
+ static struct cli_state
*
cli;
char *fname;
char *fname;
-
in
t fnum;
+
uint16_
t fnum;
int c, i;
#define MAX_EQUIVALENCE 8
smb_ucs2_t equiv[0x10000][MAX_EQUIVALENCE];
printf("starting casetable\n");
int c, i;
#define MAX_EQUIVALENCE 8
smb_ucs2_t equiv[0x10000][MAX_EQUIVALENCE];
printf("starting casetable\n");
- if (!torture_open_connection(&cli)) {
+ if (!torture_open_connection(&cli
, 0
)) {
return False;
}
memset(equiv, 0, sizeof(equiv));
return False;
}
memset(equiv, 0, sizeof(equiv));
- cli_mkdir(&cli, "\\utable");
- cli_unlink(&cli, "\\utable\\*");
+ cli_unlink(cli, "\\utable\\*", aSYSTEM | aHIDDEN);
+ cli_rmdir(cli, "\\utable");
+ if (!NT_STATUS_IS_OK(cli_mkdir(cli, "\\utable"))) {
+ printf("Failed to create utable directory!\n");
+ return False;
+ }
for (c=1; c < 0x10000; c++) {
for (c=1; c < 0x10000; c++) {
-
size_t
size;
+
SMB_OFF_T
size;
if (c == '.' || c == '\\') continue;
if (c == '.' || c == '\\') continue;
- printf("%04x
\n", c
);
+ printf("%04x
(%c)\n", c, isprint(c)?c:'.'
);
fname = form_name(c);
fname = form_name(c);
-
fnum = cli_nt_create_full(&
cli, fname, 0,
+
if (!NT_STATUS_IS_OK(cli_ntcreate(
cli, fname, 0,
GENERIC_ALL_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_NONE,
GENERIC_ALL_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_NONE,
- FILE_OPEN_IF, 0, 0);
-
- if (fnum == -1) continue;
+ FILE_OPEN_IF, 0, 0, &fnum))) {
+ printf("Failed to create file with char %04x\n", c);
+ continue;
+ }
size = 0;
size = 0;
- if (!cli_qfileinfo(&cli, fnum, NULL, &size,
- NULL, NULL, NULL, NULL, NULL)) continue;
+ if (!NT_STATUS_IS_OK(cli_qfileinfo_basic(
+ cli, fnum, NULL, &size,
+ NULL, NULL, NULL, NULL, NULL))) {
+ continue;
+ }
if (size > 0) {
/* found a character equivalence! */
int c2[MAX_EQUIVALENCE];
if (size/sizeof(int) >= MAX_EQUIVALENCE) {
if (size > 0) {
/* found a character equivalence! */
int c2[MAX_EQUIVALENCE];
if (size/sizeof(int) >= MAX_EQUIVALENCE) {
- printf("too many chars match?? size=%d c=0x%04x\n",
- size, c);
- cli_close(
&
cli, fnum);
+ printf("too many chars match?? size=%
l
d c=0x%04x\n",
+
(unsigned long)
size, c);
+ cli_close(cli, fnum);
return False;
}
return False;
}
- cli_read(
&
cli, fnum, (char *)c2, 0, size);
+ cli_read(cli, fnum, (char *)c2, 0, size);
printf("%04x: ", c);
equiv[c][0] = c;
for (i=0; i<size/sizeof(int); i++) {
printf("%04x: ", c);
equiv[c][0] = c;
for (i=0; i<size/sizeof(int); i++) {
@@
-175,12
+189,12
@@
BOOL torture_casetable(int dummy)
fflush(stdout);
}
fflush(stdout);
}
- cli_write(
&
cli, fnum, 0, (char *)&c, size, sizeof(c));
- cli_close(
&
cli, fnum);
+ cli_write(cli, fnum, 0, (char *)&c, size, sizeof(c));
+ cli_close(cli, fnum);
}
}
- cli_unlink(
&cli, "\\utable\\*"
);
- cli_rmdir(
&
cli, "\\utable");
+ cli_unlink(
cli, "\\utable\\*", aSYSTEM | aHIDDEN
);
+ cli_rmdir(cli, "\\utable");
return True;
}
return True;
}