Ignore:
Timestamp:
Jun 9, 2016, 2:23:12 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: apply latest security patches to trunk

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/librpc/ndr/libndr.h

    r918 r920  
    125125#define LIBNDR_STRING_FLAGS             (0x7FFC)
    126126
     127/*
     128 * don't debug NDR_ERR_BUFSIZE failures,
     129 * as the available buffer might be incomplete.
     130 *
     131 * return NDR_ERR_INCOMPLETE_BUFFER instead.
     132 */
     133#define LIBNDR_FLAG_INCOMPLETE_BUFFER (1<<16)
     134
     135/*
     136 * This lets ndr_pull_subcontext_end() return
     137 * NDR_ERR_UNREAD_BYTES.
     138 */
     139#define LIBNDR_FLAG_SUBCONTEXT_NO_UNREAD_BYTES (1<<17)
     140
    127141/* set if relative pointers should *not* be marshalled in reverse order */
    128142#define LIBNDR_FLAG_NO_RELATIVE_REVERSE (1<<18)
     
    164178/* useful macro for debugging */
    165179#define NDR_PRINT_DEBUG(type, p) ndr_print_debug((ndr_print_fn_t)ndr_print_ ##type, #p, p)
     180#define NDR_PRINT_DEBUGC(dbgc_class, type, p) ndr_print_debugc(dbgc_class, (ndr_print_fn_t)ndr_print_ ##type, #p, p)
    166181#define NDR_PRINT_UNION_DEBUG(type, level, p) ndr_print_union_debug((ndr_print_fn_t)ndr_print_ ##type, #p, level, p)
    167182#define NDR_PRINT_FUNCTION_DEBUG(type, flags, p) ndr_print_function_debug((ndr_print_function_t)ndr_print_ ##type, #type, flags, p)
     
    200215        NDR_ERR_INVALID_POINTER,
    201216        NDR_ERR_UNREAD_BYTES,
    202         NDR_ERR_NDR64
     217        NDR_ERR_NDR64,
     218        NDR_ERR_FLAGS,
     219        NDR_ERR_INCOMPLETE_BUFFER
    203220};
    204221
     
    218235/*
    219236  flags passed to control parse flow
     237  These are deliberately in a different range to the NDR_IN/NDR_OUT
     238  flags to catch mixups
    220239*/
    221 #define NDR_SCALARS 1
    222 #define NDR_BUFFERS 2
     240#define NDR_SCALARS    0x100
     241#define NDR_BUFFERS    0x200
    223242
    224243/*
    225   flags passed to ndr_print_*()
     244  flags passed to ndr_print_*() and ndr pull/push for functions
     245  These are deliberately in a different range to the NDR_SCALARS/NDR_BUFFERS
     246  flags to catch mixups
    226247*/
    227 #define NDR_IN 1
    228 #define NDR_OUT 2
    229 #define NDR_BOTH 3
    230 #define NDR_SET_VALUES 4
     248#define NDR_IN         0x10
     249#define NDR_OUT        0x20
     250#define NDR_BOTH       0x30
     251#define NDR_SET_VALUES 0x40
     252
     253
     254#define NDR_PULL_CHECK_FLAGS(ndr, ndr_flags) do { \
     255        if ((ndr_flags) & ~(NDR_SCALARS|NDR_BUFFERS)) { \
     256                return ndr_pull_error(ndr, NDR_ERR_FLAGS, "Invalid pull struct ndr_flags 0x%x", ndr_flags); \
     257        } \
     258} while (0)
     259
     260#define NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags) do { \
     261        if ((ndr_flags) & ~(NDR_SCALARS|NDR_BUFFERS)) \
     262                return ndr_push_error(ndr, NDR_ERR_FLAGS, "Invalid push struct ndr_flags 0x%x", ndr_flags); \
     263} while (0)
     264
     265#define NDR_PULL_CHECK_FN_FLAGS(ndr, flags) do { \
     266        if ((flags) & ~(NDR_BOTH|NDR_SET_VALUES)) { \
     267                return ndr_pull_error(ndr, NDR_ERR_FLAGS, "Invalid fn pull flags 0x%x", flags); \
     268        } \
     269} while (0)
     270
     271#define NDR_PUSH_CHECK_FN_FLAGS(ndr, flags) do { \
     272        if ((flags) & ~(NDR_BOTH|NDR_SET_VALUES)) \
     273                return ndr_push_error(ndr, NDR_ERR_FLAGS, "Invalid fn push flags 0x%x", flags); \
     274} while (0)
    231275
    232276#define NDR_PULL_NEED_BYTES(ndr, n) do { \
    233277        if (unlikely((n) > ndr->data_size || ndr->offset + (n) > ndr->data_size)) { \
     278                if (ndr->flags & LIBNDR_FLAG_INCOMPLETE_BUFFER) { \
     279                        uint32_t _available = ndr->data_size - ndr->offset; \
     280                        uint32_t _missing = n - _available; \
     281                        ndr->relative_highest_offset = _missing; \
     282                } \
    234283                return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, "Pull bytes %u (%s)", (unsigned)n, __location__); \
    235284        } \
     
    248297        } \
    249298        if (unlikely(ndr->offset > ndr->data_size)) {                   \
     299                if (ndr->flags & LIBNDR_FLAG_INCOMPLETE_BUFFER) { \
     300                        uint32_t _missing = ndr->offset - ndr->data_size; \
     301                        ndr->relative_highest_offset = _missing; \
     302                } \
    250303                return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, "Pull align %u", (unsigned)n); \
    251304        } \
     
    403456void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid);
    404457bool ndr_syntax_id_equal(const struct ndr_syntax_id *i1, const struct ndr_syntax_id *i2);
     458char *ndr_syntax_id_to_string(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *id);
     459bool ndr_syntax_id_from_string(const char *s, struct ndr_syntax_id *id);
    405460enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, const void *p, ndr_push_flags_fn_t fn);
    406461enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, uint32_t level, ndr_push_flags_fn_t fn);
     
    425480size_t ndr_align_size(uint32_t offset, size_t n);
    426481struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx);
     482enum ndr_err_code ndr_pull_append(struct ndr_pull *ndr, DATA_BLOB *blob);
     483enum ndr_err_code ndr_pull_pop(struct ndr_pull *ndr);
    427484enum ndr_err_code ndr_pull_advance(struct ndr_pull *ndr, uint32_t size);
    428485struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx);
     
    430487enum ndr_err_code ndr_push_expand(struct ndr_push *ndr, uint32_t extra_size);
    431488void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
     489void ndr_print_debugc_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
    432490void ndr_print_printf_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
    433491void ndr_print_string_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
    434492void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr);
     493void ndr_print_debugc(int dbgc_class, ndr_print_fn_t fn, const char *name, void *ptr);
    435494void ndr_print_union_debug(ndr_print_fn_t fn, const char *name, uint32_t level, void *ptr);
    436495void ndr_print_function_debug(ndr_print_function_t fn, const char *name, int flags, void *ptr);
Note: See TracChangeset for help on using the changeset viewer.