From: Joseph Sutton Date: Mon, 10 May 2021 22:29:31 +0000 (+1200) Subject: librpc: Use portable format specifiers X-Git-Tag: tevent-0.16.0~343 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acc614f28a39315a3d304919187dae2372fe60f9;p=thirdparty%2Fsamba.git librpc: Use portable format specifiers Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- diff --git a/librpc/rpc/binding.c b/librpc/rpc/binding.c index 3e2a4468f4d..8cb42d67914 100644 --- a/librpc/rpc/binding.c +++ b/librpc/rpc/binding.c @@ -194,13 +194,13 @@ const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor) return "NB_IPX"; case EPM_PROTOCOL_HTTP: - return talloc_asprintf(mem_ctx, "HTTP:%d", epm_floor->rhs.http.port); + return talloc_asprintf(mem_ctx, "HTTP:%"PRIu16, epm_floor->rhs.http.port); case EPM_PROTOCOL_TCP: - return talloc_asprintf(mem_ctx, "TCP:%d", epm_floor->rhs.tcp.port); + return talloc_asprintf(mem_ctx, "TCP:%"PRIu16, epm_floor->rhs.tcp.port); case EPM_PROTOCOL_UDP: - return talloc_asprintf(mem_ctx, "UDP:%d", epm_floor->rhs.udp.port); + return talloc_asprintf(mem_ctx, "UDP:%"PRIu16, epm_floor->rhs.udp.port); default: return talloc_asprintf(mem_ctx, "UNK(%02x):", epm_floor->lhs.protocol); @@ -987,15 +987,15 @@ char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor switch (epm_floor->lhs.protocol) { case EPM_PROTOCOL_TCP: if (epm_floor->rhs.tcp.port == 0) return NULL; - return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.tcp.port); + return talloc_asprintf(mem_ctx, "%"PRIu16, epm_floor->rhs.tcp.port); case EPM_PROTOCOL_UDP: if (epm_floor->rhs.udp.port == 0) return NULL; - return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.udp.port); + return talloc_asprintf(mem_ctx, "%"PRIu16, epm_floor->rhs.udp.port); case EPM_PROTOCOL_HTTP: if (epm_floor->rhs.http.port == 0) return NULL; - return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.http.port); + return talloc_asprintf(mem_ctx, "%"PRIu16, epm_floor->rhs.http.port); case EPM_PROTOCOL_IP: return talloc_strdup(mem_ctx, epm_floor->rhs.ip.ipaddr); @@ -1022,10 +1022,10 @@ char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor return NULL; case EPM_PROTOCOL_VINES_SPP: - return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.vines_spp.port); + return talloc_asprintf(mem_ctx, "%"PRIu16, epm_floor->rhs.vines_spp.port); case EPM_PROTOCOL_VINES_IPC: - return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.vines_ipc.port); + return talloc_asprintf(mem_ctx, "%"PRIu16, epm_floor->rhs.vines_ipc.port); case EPM_PROTOCOL_STREETTALK: return talloc_strdup(mem_ctx, epm_floor->rhs.streettalk.streettalk); diff --git a/librpc/rpc/dcerpc_util.c b/librpc/rpc/dcerpc_util.c index a3a734b0c09..a1f311e57b7 100644 --- a/librpc/rpc/dcerpc_util.c +++ b/librpc/rpc/dcerpc_util.c @@ -331,9 +331,9 @@ NTSTATUS dcerpc_pull_auth_trailer(const struct ncacn_packet *pkt, } if (max_pad_len < auth->auth_pad_length) { DEBUG(1, (__location__ ": ERROR: pad length to large. " - "max %u got %u\n", - (unsigned)max_pad_len, - (unsigned)auth->auth_pad_length)); + "max %"PRIu32" got %"PRIu8"\n", + max_pad_len, + auth->auth_pad_length)); talloc_free(ndr); ZERO_STRUCTP(auth); return NT_STATUS_RPC_PROTOCOL_ERROR; @@ -357,12 +357,12 @@ NTSTATUS dcerpc_pull_auth_trailer(const struct ncacn_packet *pkt, if (data_and_pad < auth->auth_pad_length) { DBG_WARNING(__location__ ": ERROR: pad length too long. " - "Calculated %u (pkt_trailer->length=%u - auth_length=%u) " - "was less than auth_pad_length=%u\n", - (unsigned)data_and_pad, - (unsigned)pkt_trailer->length, - (unsigned)auth_length, - (unsigned)auth->auth_pad_length); + "Calculated %"PRIu16" (pkt_trailer->length=%zu - auth_length=%"PRIu16") " + "was less than auth_pad_length=%"PRIu8"\n", + data_and_pad, + pkt_trailer->length, + auth_length, + auth->auth_pad_length); talloc_free(ndr); ZERO_STRUCTP(auth); return NT_STATUS_RPC_PROTOCOL_ERROR; @@ -370,14 +370,14 @@ NTSTATUS dcerpc_pull_auth_trailer(const struct ncacn_packet *pkt, if (auth_data_only && data_and_pad > auth->auth_pad_length) { DBG_WARNING(__location__ ": ERROR: auth_data_only pad length mismatch. " - "Client sent a longer BIND packet than expected by %u bytes " - "(pkt_trailer->length=%u - auth_length=%u) " - "= %u auth_pad_length=%u\n", - (unsigned)data_and_pad - (unsigned)auth->auth_pad_length, - (unsigned)pkt_trailer->length, - (unsigned)auth_length, - (unsigned)data_and_pad, - (unsigned)auth->auth_pad_length); + "Client sent a longer BIND packet than expected by %"PRIu16" bytes " + "(pkt_trailer->length=%zu - auth_length=%"PRIu16") " + "= %"PRIu16" auth_pad_length=%"PRIu8"\n", + data_and_pad - auth->auth_pad_length, + pkt_trailer->length, + auth_length, + data_and_pad, + auth->auth_pad_length); talloc_free(ndr); ZERO_STRUCTP(auth); return NT_STATUS_RPC_PROTOCOL_ERROR; @@ -385,19 +385,19 @@ NTSTATUS dcerpc_pull_auth_trailer(const struct ncacn_packet *pkt, if (auth_data_only && data_and_pad != auth->auth_pad_length) { DBG_WARNING(__location__ ": ERROR: auth_data_only pad length mismatch. " - "Calculated %u (pkt_trailer->length=%u - auth_length=%u) " - "but auth_pad_length=%u\n", - (unsigned)data_and_pad, - (unsigned)pkt_trailer->length, - (unsigned)auth_length, - (unsigned)auth->auth_pad_length); + "Calculated %"PRIu16" (pkt_trailer->length=%zu - auth_length=%"PRIu16") " + "but auth_pad_length=%"PRIu8"\n", + data_and_pad, + pkt_trailer->length, + auth_length, + auth->auth_pad_length); talloc_free(ndr); ZERO_STRUCTP(auth); return NT_STATUS_RPC_PROTOCOL_ERROR; } - DBG_DEBUG("auth_pad_length %u\n", - (unsigned)auth->auth_pad_length); + DBG_DEBUG("auth_pad_length %"PRIu8"\n", + auth->auth_pad_length); talloc_steal(mem_ctx, auth->credentials.data); talloc_free(ndr); @@ -1121,7 +1121,7 @@ void dcerpc_log_packet(const char *packet_log_dir, char *name=NULL; int ret; bool saved; - ret = asprintf(&name, "%s/%s-%u.%d.%s.%s", + ret = asprintf(&name, "%s/%s-%"PRIu32".%d.%s.%s", packet_log_dir, interface_name, opnum, i, (flags&NDR_IN)?"in":"out", why); diff --git a/librpc/rpc/dcesrv_core.c b/librpc/rpc/dcesrv_core.c index 09ea6812249..35fb7aa853d 100644 --- a/librpc/rpc/dcesrv_core.c +++ b/librpc/rpc/dcesrv_core.c @@ -1934,7 +1934,7 @@ static NTSTATUS dcesrv_request(struct dcesrv_call_state *call) uint8_t extra_flags = 0; if (call->fault_code == DCERPC_FAULT_OP_RNG_ERROR) { /* we got an unknown call */ - DEBUG(3,(__location__ ": Unknown RPC call %u on %s\n", + DEBUG(3,(__location__ ": Unknown RPC call %"PRIu16" on %s\n", call->pkt.u.request.opnum, call->context->iface->name)); dcesrv_save_call(call, "unknown"); @@ -1952,7 +1952,7 @@ static NTSTATUS dcesrv_request(struct dcesrv_call_state *call) if (pull->offset != pull->data_size) { dcesrv_save_call(call, "extrabytes"); - DEBUG(3,("Warning: %d extra bytes in incoming RPC request\n", + DEBUG(3,("Warning: %"PRIu32" extra bytes in incoming RPC request\n", pull->data_size - pull->offset)); } diff --git a/librpc/tools/ndrdump.c b/librpc/tools/ndrdump.c index 26f885ccd10..a81d8062443 100644 --- a/librpc/tools/ndrdump.c +++ b/librpc/tools/ndrdump.c @@ -220,9 +220,9 @@ static NTSTATUS ndrdump_pull_and_print_pipes(const char *function, */ count = (uint32_t *)c; - n = talloc_asprintf(c, "%s: %s[%llu]", + n = talloc_asprintf(c, "%s: %s[%"PRIu64"]", function, pipes->pipes[i].name, - (unsigned long long)idx); + idx); saved_mem_ctx = ndr_pull->current_mem_ctx; ndr_pull->current_mem_ctx = c; @@ -458,8 +458,8 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...) st = talloc_zero_size(mem_ctx, f->struct_size); if (!st) { - printf("Unable to allocate %d bytes for %s structure\n", - (int)f->struct_size, + printf("Unable to allocate %zu bytes for %s structure\n", + f->struct_size, f->name); TALLOC_FREE(mem_ctx); exit(1); @@ -467,9 +467,9 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...) v_st = talloc_zero_size(mem_ctx, f->struct_size); if (!v_st) { - printf("Unable to allocate %d bytes for %s validation " + printf("Unable to allocate %zu bytes for %s validation " "structure\n", - (int)f->struct_size, + f->struct_size, f->name); TALLOC_FREE(mem_ctx); exit(1); @@ -511,7 +511,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...) } if (highest_ofs != ndr_pull->data_size) { - printf("WARNING! %d unread bytes while parsing context file\n", ndr_pull->data_size - highest_ofs); + printf("WARNING! %"PRIu32" unread bytes while parsing context file\n", ndr_pull->data_size - highest_ofs); } if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -594,8 +594,8 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...) } if (sec_vt != NULL && sec_vt->count.count > 0) { - printf("SEC_VT: consumed %d bytes\n", - (int)(blob.length - ndr_pull->data_size)); + printf("SEC_VT: consumed %zu bytes\n", + blob.length - ndr_pull->data_size); if (dumpdata) { ndrdump_data(blob.data + ndr_pull->data_size, blob.length - ndr_pull->data_size, @@ -629,7 +629,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...) } if (dumpdata) { - printf("%d bytes consumed\n", highest_ofs); + printf("%"PRIu32" bytes consumed\n", highest_ofs); ndrdump_data(blob.data, blob.length, dumpdata); } @@ -639,7 +639,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...) } if (highest_ofs != ndr_pull->data_size) { - printf("WARNING! %d unread bytes\n", ndr_pull->data_size - highest_ofs); + printf("WARNING! %"PRIu32" unread bytes\n", ndr_pull->data_size - highest_ofs); ndrdump_data(ndr_pull->data+highest_ofs, ndr_pull->data_size - highest_ofs, dumpdata); @@ -705,7 +705,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...) v_blob = ndr_push_blob(ndr_v_push); if (dumpdata) { - printf("%ld bytes generated (validate)\n", (long)v_blob.length); + printf("%zu bytes generated (validate)\n", v_blob.length); ndrdump_data(v_blob.data, v_blob.length, dumpdata); } @@ -733,7 +733,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...) } if (highest_v_ofs != ndr_v_pull->data_size) { - printf("WARNING! %d unread bytes in validation\n", + printf("WARNING! %"PRIu32" unread bytes in validation\n", ndr_v_pull->data_size - highest_v_ofs); ndrdump_data(ndr_v_pull->data + highest_v_ofs, ndr_v_pull->data_size - highest_v_ofs, @@ -748,13 +748,13 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...) flags, v_st); if (blob.length != v_blob.length) { - printf("WARNING! orig bytes:%llu validated pushed bytes:%llu\n", - (unsigned long long)blob.length, (unsigned long long)v_blob.length); + printf("WARNING! orig bytes:%zu validated pushed bytes:%zu\n", + blob.length, v_blob.length); } if (highest_ofs != highest_v_ofs) { - printf("WARNING! orig pulled bytes:%llu validated pulled bytes:%llu\n", - (unsigned long long)highest_ofs, (unsigned long long)highest_v_ofs); + printf("WARNING! orig pulled bytes:%"PRIu32" validated pulled bytes:%"PRIu32"\n", + highest_ofs, highest_v_ofs); } differ = false; @@ -777,8 +777,8 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...) } } if (differ) { - printf("WARNING! orig and validated differ at byte 0x%02X (%u)\n", i, i); - printf("WARNING! orig byte[0x%02X] = 0x%02X validated byte[0x%02X] = 0x%02X\n", + printf("WARNING! orig and validated differ at byte 0x%02"PRIX32" (%"PRIu32")\n", i, i); + printf("WARNING! orig byte[0x%02"PRIX32"] = 0x%02"PRIX8" validated byte[0x%02"PRIX32"] = 0x%02"PRIX8"\n", i, byte_a, i, byte_b); ndrdump_data_diff(blob.data, blob.length, v_blob.data, v_blob.length,