mirror of
https://github.com/samba-team/samba.git
synced 2024-12-28 07:21:54 +03:00
librpc: remove special support for fixed length strings
Fixed arrays with the charset() attribute do the same
metze
(This used to be commit 9620b86e96
)
This commit is contained in:
parent
1f3e4e2dea
commit
be25cdebcb
@ -5,8 +5,6 @@
|
||||
#define STR_NOTERM LIBNDR_FLAG_STR_NOTERM
|
||||
#define STR_NULLTERM LIBNDR_FLAG_STR_NULLTERM
|
||||
#define STR_BYTESIZE LIBNDR_FLAG_STR_BYTESIZE
|
||||
#define STR_FIXLEN32 LIBNDR_FLAG_STR_FIXLEN32
|
||||
#define STR_FIXLEN15 LIBNDR_FLAG_STR_FIXLEN15
|
||||
#define STR_CONFORMANT LIBNDR_FLAG_STR_CONFORMANT
|
||||
#define STR_CHARLEN LIBNDR_FLAG_STR_CHARLEN
|
||||
#define STR_UTF8 LIBNDR_FLAG_STR_UTF8
|
||||
@ -21,16 +19,6 @@
|
||||
*/
|
||||
#define nstring [flag(STR_NULLTERM)] string
|
||||
|
||||
/*
|
||||
fixed length 32 character UCS-2 string
|
||||
*/
|
||||
#define string32 [flag(STR_FIXLEN32)] string
|
||||
|
||||
/*
|
||||
fixed length 16 character ascii string
|
||||
*/
|
||||
#define astring15 [flag(STR_ASCII|STR_FIXLEN15)] string
|
||||
|
||||
/*
|
||||
an ascii string prefixed with [offset] [length], both 32 bits
|
||||
null terminated
|
||||
|
@ -109,11 +109,9 @@ struct ndr_print {
|
||||
#define LIBNDR_FLAG_STR_NULLTERM (1<<6)
|
||||
#define LIBNDR_FLAG_STR_SIZE2 (1<<7)
|
||||
#define LIBNDR_FLAG_STR_BYTESIZE (1<<8)
|
||||
#define LIBNDR_FLAG_STR_FIXLEN32 (1<<9)
|
||||
#define LIBNDR_FLAG_STR_CONFORMANT (1<<10)
|
||||
#define LIBNDR_FLAG_STR_CHARLEN (1<<11)
|
||||
#define LIBNDR_FLAG_STR_UTF8 (1<<12)
|
||||
#define LIBNDR_FLAG_STR_FIXLEN15 (1<<13)
|
||||
#define LIBNDR_STRING_FLAGS (0x7FFC)
|
||||
|
||||
|
||||
|
@ -259,24 +259,6 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
|
||||
*s = as;
|
||||
break;
|
||||
|
||||
case LIBNDR_FLAG_STR_FIXLEN15:
|
||||
case LIBNDR_FLAG_STR_FIXLEN32:
|
||||
len1 = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15;
|
||||
NDR_PULL_NEED_BYTES(ndr, len1*byte_mul);
|
||||
ret = convert_string_talloc(ndr->current_mem_ctx,
|
||||
ndr->iconv_convenience,
|
||||
chset, CH_UNIX,
|
||||
ndr->data+ndr->offset,
|
||||
len1*byte_mul,
|
||||
(void **)&as);
|
||||
if (ret == -1) {
|
||||
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
|
||||
"Bad character conversion");
|
||||
}
|
||||
NDR_CHECK(ndr_pull_advance(ndr, len1*byte_mul));
|
||||
*s = as;
|
||||
break;
|
||||
|
||||
case LIBNDR_FLAG_STR_NOTERM:
|
||||
if (!(ndr->flags & LIBNDR_FLAG_REMAINING)) {
|
||||
return ndr_pull_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x (missing NDR_REMAINING)\n",
|
||||
@ -349,10 +331,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags,
|
||||
|
||||
flags &= ~LIBNDR_FLAG_STR_CONFORMANT;
|
||||
|
||||
if (!(flags &
|
||||
(LIBNDR_FLAG_STR_NOTERM |
|
||||
LIBNDR_FLAG_STR_FIXLEN15 |
|
||||
LIBNDR_FLAG_STR_FIXLEN32))) {
|
||||
if (!(flags & LIBNDR_FLAG_STR_NOTERM)) {
|
||||
s_len++;
|
||||
}
|
||||
d_len = convert_string_talloc(ndr, ndr->iconv_convenience, CH_UNIX, chset, s, s_len, (void **)&dest);
|
||||
@ -399,21 +378,6 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags,
|
||||
NDR_CHECK(ndr_push_bytes(ndr, dest, d_len));
|
||||
break;
|
||||
|
||||
case LIBNDR_FLAG_STR_FIXLEN15:
|
||||
case LIBNDR_FLAG_STR_FIXLEN32: {
|
||||
ssize_t fix_len = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15;
|
||||
uint32_t pad_len = fix_len - d_len;
|
||||
if (d_len > fix_len) {
|
||||
return ndr_push_error(ndr, NDR_ERR_CHARCNV,
|
||||
"Bad character conversion");
|
||||
}
|
||||
NDR_CHECK(ndr_push_bytes(ndr, dest, d_len));
|
||||
if (pad_len != 0) {
|
||||
NDR_CHECK(ndr_push_zero(ndr, pad_len));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
if (ndr->flags & LIBNDR_FLAG_REMAINING) {
|
||||
NDR_CHECK(ndr_push_bytes(ndr, dest, d_len));
|
||||
@ -439,13 +403,6 @@ _PUBLIC_ size_t ndr_string_array_size(struct ndr_push *ndr, const char *s)
|
||||
unsigned byte_mul = 2;
|
||||
unsigned c_len_term = 1;
|
||||
|
||||
if (flags & LIBNDR_FLAG_STR_FIXLEN32) {
|
||||
return 32;
|
||||
}
|
||||
if (flags & LIBNDR_FLAG_STR_FIXLEN15) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
c_len = s?strlen_m(s):0;
|
||||
|
||||
if (flags & (LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_UTF8)) {
|
||||
|
Loading…
Reference in New Issue
Block a user