}} while (0)
#define CHECK_WSTR(field, value, flags) do { \
- if (!field.s || strcmp(field.s, value) || wire_bad_flags(&field, flags)) { \
+ if (!field.s || strcmp(field.s, value) || wire_bad_flags(&field, flags, cli)) { \
printf("(%d) %s [%s] != %s\n", __LINE__, #field, field.s, value); \
ret = False; \
goto done; \
#define NAME_CHECK(sname, stype, tfield, flags) do { \
s1 = fnum_find(sname); \
if (s1 && (strcmp(s1->stype.out.tfield.s, correct_name) != 0 || \
- wire_bad_flags(&s1->stype.out.tfield, flags))) { \
+ wire_bad_flags(&s1->stype.out.tfield, flags, cli))) { \
printf("(%d) handle %s/%s incorrect - '%s/%d'\n", __LINE__, #stype, #tfield, \
s1->stype.out.tfield.s, s1->stype.out.tfield.private_length); \
ret = False; \
} \
s1 = fname_find(sname); \
if (s1 && (strcmp(s1->stype.out.tfield.s, correct_name) != 0 || \
- wire_bad_flags(&s1->stype.out.tfield, flags))) { \
+ wire_bad_flags(&s1->stype.out.tfield, flags, cli))) { \
printf("(%d) path %s/%s incorrect - '%s/%d'\n", __LINE__, #stype, #tfield, \
s1->stype.out.tfield.s, s1->stype.out.tfield.private_length); \
ret = False; \
ret = False;
}
}
- if (wire_bad_flags(&s1->all_info.out.fname, STR_UNICODE)) {
+ if (wire_bad_flags(&s1->all_info.out.fname, STR_UNICODE, cli)) {
printf("Should not null terminate all_info/fname\n");
ret = False;
}
#define STR_CHECK(sname, stype, field, flags) do { \
s1 = find(sname); \
if (s1) { \
- if (wire_bad_flags(&s1->stype.out.field, flags)) { \
+ if (wire_bad_flags(&s1->stype.out.field, flags, cli)) { \
printf("(%d) incorrect string termination in %s/%s\n", \
__LINE__, #stype, #field); \
ret = False; \
if (s) { \
if (!s->sname1.field1.s || \
strcmp(s->sname1.field1.s, v.sname2.out.field2.s) || \
- wire_bad_flags(&s->sname1.field1, flags)) { \
+ wire_bad_flags(&s->sname1.field1, flags, cli)) { \
printf("(%d) %s/%s [%s] != %s/%s [%s]\n", \
__LINE__, \
#sname1, #field1, s->sname1.field1.s, \
if (s) { \
if (!s->sname1.field1.s || \
strcmp(s->sname1.field1.s, fname) || \
- wire_bad_flags(&s->sname1.field1, flags)) { \
+ wire_bad_flags(&s->sname1.field1, flags, cli)) { \
printf("(%d) %s/%s [%s] != %s\n", \
__LINE__, \
#sname1, #field1, s->sname1.field1.s, \
check that a wire string matches the flags specified
not 100% accurate, but close enough for testing
*/
-BOOL wire_bad_flags(WIRE_STRING *str, int flags)
+BOOL wire_bad_flags(WIRE_STRING *str, int flags, struct smbcli_state *cli)
{
+ BOOL server_unicode;
int len;
if (!str || !str->s) return True;
len = strlen(str->s);
if (flags & STR_TERMINATE) len++;
- if ((flags & STR_UNICODE) || !getenv("CLI_FORCE_ASCII")) {
+
+ server_unicode = (cli->transport->negotiate.capabilities&CAP_UNICODE)?True:False;
+ if (getenv("CLI_FORCE_ASCII") || !lp_unicode()) {
+ server_unicode = False;
+ }
+
+ if ((flags & STR_UNICODE) || server_unicode) {
len *= 2;
} else if (flags & STR_TERMINATE_ASCII) {
len++;