mirror of
https://github.com/samba-team/samba.git
synced 2025-01-13 13:18:06 +03:00
fixed some unicode and LANMAN2 bugs in trans2 find first
This commit is contained in:
parent
7a478e050f
commit
dc99b9ddf8
@ -34,120 +34,94 @@ static int interpret_long_filename(struct cli_state *cli,
|
|||||||
int level,char *p,file_info *finfo)
|
int level,char *p,file_info *finfo)
|
||||||
{
|
{
|
||||||
extern file_info def_finfo;
|
extern file_info def_finfo;
|
||||||
|
file_info finfo2;
|
||||||
|
int len;
|
||||||
|
char *base = p;
|
||||||
|
|
||||||
if (finfo)
|
if (!finfo) finfo = &finfo2;
|
||||||
memcpy(finfo,&def_finfo,sizeof(*finfo));
|
|
||||||
|
memcpy(finfo,&def_finfo,sizeof(*finfo));
|
||||||
|
|
||||||
switch (level)
|
switch (level)
|
||||||
{
|
{
|
||||||
case 1: /* OS/2 understands this */
|
case 1: /* OS/2 understands this */
|
||||||
if (finfo) {
|
/* these dates are converted to GMT by
|
||||||
/* these dates are converted to GMT by make_unix_date */
|
make_unix_date */
|
||||||
finfo->ctime = make_unix_date2(p+4);
|
finfo->ctime = make_unix_date2(p+4);
|
||||||
finfo->atime = make_unix_date2(p+8);
|
finfo->atime = make_unix_date2(p+8);
|
||||||
finfo->mtime = make_unix_date2(p+12);
|
finfo->mtime = make_unix_date2(p+12);
|
||||||
finfo->size = IVAL(p,16);
|
finfo->size = IVAL(p,16);
|
||||||
finfo->mode = CVAL(p,24);
|
finfo->mode = CVAL(p,24);
|
||||||
clistr_pull(cli, finfo->name, p+27,
|
len = CVAL(p, 26);
|
||||||
sizeof(finfo->name),
|
p += 27;
|
||||||
-1,
|
p += clistr_align_in(cli, p, 0);
|
||||||
STR_TERMINATE);
|
p += clistr_pull(cli, finfo->name, p,
|
||||||
}
|
sizeof(finfo->name),
|
||||||
return(28 + CVAL(p,26));
|
len,
|
||||||
|
STR_TERMINATE);
|
||||||
|
return PTR_DIFF(p, base);
|
||||||
|
|
||||||
case 2: /* this is what OS/2 uses mostly */
|
case 2: /* this is what OS/2 uses mostly */
|
||||||
if (finfo) {
|
/* these dates are converted to GMT by
|
||||||
/* these dates are converted to GMT by make_unix_date */
|
make_unix_date */
|
||||||
finfo->ctime = make_unix_date2(p+4);
|
finfo->ctime = make_unix_date2(p+4);
|
||||||
finfo->atime = make_unix_date2(p+8);
|
finfo->atime = make_unix_date2(p+8);
|
||||||
finfo->mtime = make_unix_date2(p+12);
|
finfo->mtime = make_unix_date2(p+12);
|
||||||
finfo->size = IVAL(p,16);
|
finfo->size = IVAL(p,16);
|
||||||
finfo->mode = CVAL(p,24);
|
finfo->mode = CVAL(p,24);
|
||||||
clistr_pull(cli, finfo->name, p+31,
|
len = CVAL(p, 30);
|
||||||
sizeof(finfo->name),
|
p += 31;
|
||||||
-1,
|
p += clistr_pull(cli, finfo->name, p,
|
||||||
STR_TERMINATE);
|
sizeof(finfo->name),
|
||||||
}
|
len,
|
||||||
return(32 + CVAL(p,30));
|
STR_NOALIGN);
|
||||||
|
return PTR_DIFF(p, base) + 1;
|
||||||
/* levels 3 and 4 are untested */
|
|
||||||
case 3:
|
|
||||||
if (finfo) {
|
|
||||||
/* these dates are probably like the other ones */
|
|
||||||
finfo->ctime = make_unix_date2(p+8);
|
|
||||||
finfo->atime = make_unix_date2(p+12);
|
|
||||||
finfo->mtime = make_unix_date2(p+16);
|
|
||||||
finfo->size = IVAL(p,20);
|
|
||||||
finfo->mode = CVAL(p,28);
|
|
||||||
clistr_pull(cli, finfo->name, p+33,
|
|
||||||
sizeof(finfo->name),
|
|
||||||
-1,
|
|
||||||
STR_TERMINATE);
|
|
||||||
}
|
|
||||||
return(SVAL(p,4)+4);
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
if (finfo) {
|
|
||||||
/* these dates are probably like the other ones */
|
|
||||||
finfo->ctime = make_unix_date2(p+8);
|
|
||||||
finfo->atime = make_unix_date2(p+12);
|
|
||||||
finfo->mtime = make_unix_date2(p+16);
|
|
||||||
finfo->size = IVAL(p,20);
|
|
||||||
finfo->mode = CVAL(p,28);
|
|
||||||
clistr_pull(cli, finfo->name, p+37,
|
|
||||||
sizeof(finfo->name),
|
|
||||||
-1,
|
|
||||||
STR_TERMINATE);
|
|
||||||
}
|
|
||||||
return(SVAL(p,4)+4);
|
|
||||||
|
|
||||||
case 260: /* NT uses this, but also accepts 2 */
|
case 260: /* NT uses this, but also accepts 2 */
|
||||||
if (finfo) {
|
{
|
||||||
int ret = SVAL(p,0);
|
int namelen, slen;
|
||||||
int namelen, slen;
|
p += 4; /* next entry offset */
|
||||||
p += 4; /* next entry offset */
|
p += 4; /* fileindex */
|
||||||
p += 4; /* fileindex */
|
|
||||||
|
|
||||||
/* these dates appear to arrive in a
|
/* these dates appear to arrive in a
|
||||||
weird way. It seems to be localtime
|
weird way. It seems to be localtime
|
||||||
plus the serverzone given in the
|
plus the serverzone given in the
|
||||||
initial connect. This is GMT when
|
initial connect. This is GMT when
|
||||||
DST is not in effect and one hour
|
DST is not in effect and one hour
|
||||||
from GMT otherwise. Can this really
|
from GMT otherwise. Can this really
|
||||||
be right??
|
be right??
|
||||||
|
|
||||||
I suppose this could be called
|
I suppose this could be called
|
||||||
kludge-GMT. Is is the GMT you get
|
kludge-GMT. Is is the GMT you get
|
||||||
by using the current DST setting on
|
by using the current DST setting on
|
||||||
a different localtime. It will be
|
a different localtime. It will be
|
||||||
cheap to calculate, I suppose, as
|
cheap to calculate, I suppose, as
|
||||||
no DST tables will be needed */
|
no DST tables will be needed */
|
||||||
|
|
||||||
finfo->ctime = interpret_long_date(p); p += 8;
|
finfo->ctime = interpret_long_date(p); p += 8;
|
||||||
finfo->atime = interpret_long_date(p); p += 8;
|
finfo->atime = interpret_long_date(p); p += 8;
|
||||||
finfo->mtime = interpret_long_date(p); p += 8; p += 8;
|
finfo->mtime = interpret_long_date(p); p += 8; p += 8;
|
||||||
finfo->size = IVAL(p,0); p += 8;
|
finfo->size = IVAL(p,0); p += 8;
|
||||||
p += 8; /* alloc size */
|
p += 8; /* alloc size */
|
||||||
finfo->mode = CVAL(p,0); p += 4;
|
finfo->mode = CVAL(p,0); p += 4;
|
||||||
namelen = IVAL(p,0); p += 4;
|
namelen = IVAL(p,0); p += 4;
|
||||||
p += 4; /* EA size */
|
p += 4; /* EA size */
|
||||||
slen = SVAL(p, 0);
|
slen = SVAL(p, 0);
|
||||||
p += 2;
|
p += 2;
|
||||||
{
|
{
|
||||||
/* stupid NT bugs. grr */
|
/* stupid NT bugs. grr */
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
if (p[1] == 0 && namelen > 1) flags |= STR_UNICODE;
|
if (p[1] == 0 && namelen > 1) flags |= STR_UNICODE;
|
||||||
clistr_pull(cli, finfo->short_name, p,
|
clistr_pull(cli, finfo->short_name, p,
|
||||||
sizeof(finfo->short_name),
|
sizeof(finfo->short_name),
|
||||||
24, flags);
|
24, flags);
|
||||||
}
|
|
||||||
p += 24; /* short name? */
|
|
||||||
clistr_pull(cli, finfo->name, p,
|
|
||||||
sizeof(finfo->name),
|
|
||||||
namelen, 0);
|
|
||||||
return(ret);
|
|
||||||
}
|
}
|
||||||
return(SVAL(p,0));
|
p += 24; /* short name? */
|
||||||
|
clistr_pull(cli, finfo->name, p,
|
||||||
|
sizeof(finfo->name),
|
||||||
|
namelen, 0);
|
||||||
|
return SVAL(base, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(1,("Unknown long filename format %d\n",level));
|
DEBUG(1,("Unknown long filename format %d\n",level));
|
||||||
|
Loading…
Reference in New Issue
Block a user