1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-04 08:22:08 +03:00

r204: Turns out that the string in the SEARCH unix_info level is that

rare thing, a non-length string (ie. not a WIRE_STRING) but a null
terminated char string. There wasn't a good interface to pull that
out of a blob (all the string interfaces assumed WIRE_STRINGS). Added
a new one, only used for this call. Sucks, I know - but the alternatives
suck more. Added tests for some of the unix info returned.
Jeremy.
(This used to be commit 4d0ed04c54)
This commit is contained in:
Jeremy Allison
2004-04-14 01:09:41 +00:00
committed by Gerald (Jerry) Carter
parent 6f47ce8b6c
commit 763c4bc9ac
4 changed files with 65 additions and 6 deletions

View File

@ -1007,6 +1007,52 @@ size_t cli_blob_pull_string(struct cli_session *session,
blob->data+str_offset, dest->private_length, flags);
}
/*
pull a string from a blob, returning a talloced char *
Currently only used by the UNIX search info level.
the string length is limited by 2 things:
- the data size in the blob
- the end of string (null termination)
on failure zero is returned and dest->s is set to NULL, otherwise the number
of bytes consumed in the blob is returned
*/
size_t cli_blob_pull_unix_string(struct cli_session *session,
TALLOC_CTX *mem_ctx,
DATA_BLOB *blob,
const char **dest,
uint16 str_offset,
unsigned flags)
{
int extra = 0;
*dest = NULL;
if (!(flags & STR_ASCII) &&
((flags & STR_UNICODE) ||
(session->transport->negotiate.capabilities & CAP_UNICODE))) {
int align = 0;
if ((str_offset&1) && !(flags & STR_NOALIGN)) {
align = 1;
}
if (flags & STR_LEN_NOTERM) {
extra = 2;
}
return align + extra + cli_blob_pull_ucs2(mem_ctx, blob, dest,
blob->data+str_offset+align,
-1, flags);
}
if (flags & STR_LEN_NOTERM) {
extra = 1;
}
return extra + cli_blob_pull_ascii(mem_ctx, blob, dest,
blob->data+str_offset, -1, flags);
}
/*
append a string into a blob
*/