mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
Add MAX_DNS_NAME_LENGTH, remove more pstrings.
Jeremy.
(This used to be commit a1725f4ff7
)
This commit is contained in:
parent
c261545449
commit
acb829ecc3
@ -540,4 +540,8 @@ typedef int bool;
|
|||||||
#define PATH_MAX 1024
|
#define PATH_MAX 1024
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAX_DNS_NAME_LENGTH
|
||||||
|
#define MAX_DNS_NAME_LENGTH 256 /* Actually 255 but +1 for terminating null. */
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _LIBREPLACE_REPLACE_H */
|
#endif /* _LIBREPLACE_REPLACE_H */
|
||||||
|
@ -1802,8 +1802,8 @@ const char *get_peer_name(int fd,
|
|||||||
socklen_t length = sizeof(ss);
|
socklen_t length = sizeof(ss);
|
||||||
const char *p;
|
const char *p;
|
||||||
int ret;
|
int ret;
|
||||||
char name_buf[HOST_NAME_MAX];
|
char name_buf[MAX_DNS_NAME_LENGTH];
|
||||||
char tmp_name[HOST_NAME_MAX];
|
char tmp_name[MAX_DNS_NAME_LENGTH];
|
||||||
|
|
||||||
/* reverse lookups can be *very* expensive, and in many
|
/* reverse lookups can be *very* expensive, and in many
|
||||||
situations won't work because many networks don't link dhcp
|
situations won't work because many networks don't link dhcp
|
||||||
|
@ -77,7 +77,7 @@ static bool ads_dns_parse_query( TALLOC_CTX *ctx, uint8 *start, uint8 *end,
|
|||||||
uint8 **ptr, struct dns_query *q )
|
uint8 **ptr, struct dns_query *q )
|
||||||
{
|
{
|
||||||
uint8 *p = *ptr;
|
uint8 *p = *ptr;
|
||||||
pstring hostname;
|
char hostname[MAX_DNS_NAME_LENGTH];
|
||||||
int namelen;
|
int namelen;
|
||||||
|
|
||||||
ZERO_STRUCTP( q );
|
ZERO_STRUCTP( q );
|
||||||
@ -115,7 +115,7 @@ static bool ads_dns_parse_rr( TALLOC_CTX *ctx, uint8 *start, uint8 *end,
|
|||||||
uint8 **ptr, struct dns_rr *rr )
|
uint8 **ptr, struct dns_rr *rr )
|
||||||
{
|
{
|
||||||
uint8 *p = *ptr;
|
uint8 *p = *ptr;
|
||||||
pstring hostname;
|
char hostname[MAX_DNS_NAME_LENGTH];
|
||||||
int namelen;
|
int namelen;
|
||||||
|
|
||||||
if ( !start || !end || !rr || !*ptr)
|
if ( !start || !end || !rr || !*ptr)
|
||||||
@ -170,7 +170,7 @@ static bool ads_dns_parse_rr_srv( TALLOC_CTX *ctx, uint8 *start, uint8 *end,
|
|||||||
{
|
{
|
||||||
struct dns_rr rr;
|
struct dns_rr rr;
|
||||||
uint8 *p;
|
uint8 *p;
|
||||||
pstring dcname;
|
char dcname[MAX_DNS_NAME_LENGTH];
|
||||||
int namelen;
|
int namelen;
|
||||||
|
|
||||||
if ( !start || !end || !srv || !*ptr)
|
if ( !start || !end || !srv || !*ptr)
|
||||||
@ -216,7 +216,7 @@ static bool ads_dns_parse_rr_ns( TALLOC_CTX *ctx, uint8 *start, uint8 *end,
|
|||||||
{
|
{
|
||||||
struct dns_rr rr;
|
struct dns_rr rr;
|
||||||
uint8 *p;
|
uint8 *p;
|
||||||
pstring nsname;
|
char nsname[MAX_DNS_NAME_LENGTH];
|
||||||
int namelen;
|
int namelen;
|
||||||
|
|
||||||
if ( !start || !end || !nsrec || !*ptr)
|
if ( !start || !end || !nsrec || !*ptr)
|
||||||
|
@ -31,7 +31,7 @@ NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx,
|
|||||||
char **unix_path)
|
char **unix_path)
|
||||||
{
|
{
|
||||||
fstring tok;
|
fstring tok;
|
||||||
pstring path;
|
char *path = NULL;
|
||||||
|
|
||||||
*server = NULL;
|
*server = NULL;
|
||||||
*service = NULL;
|
*service = NULL;
|
||||||
@ -63,15 +63,22 @@ NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx,
|
|||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
pstrcpy(path, lock_path(GPO_CACHE_DIR));
|
if ((path = talloc_asprintf(mem_ctx,
|
||||||
pstrcat(path, "/");
|
"%s/%s",
|
||||||
pstrcat(path, file_sys_path);
|
lock_path(GPO_CACHE_DIR),
|
||||||
pstring_sub(path, "\\", "/");
|
file_sys_path)) == NULL) {
|
||||||
|
return NT_STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
path = talloc_string_sub(mem_ctx, path, "\\", "/");
|
||||||
|
if (!path) {
|
||||||
|
return NT_STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
if ((*unix_path = talloc_strdup(mem_ctx, path)) == NULL) {
|
if ((*unix_path = talloc_strdup(mem_ctx, path)) == NULL) {
|
||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TALLOC_FREE(path);
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ struct sync_context {
|
|||||||
struct cli_state *cli;
|
struct cli_state *cli;
|
||||||
char *remote_path;
|
char *remote_path;
|
||||||
char *local_path;
|
char *local_path;
|
||||||
pstring mask;
|
char *mask;
|
||||||
uint16_t attribute;
|
uint16_t attribute;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -171,9 +171,13 @@ static void gpo_sync_func(const char *mnt,
|
|||||||
old_unix_dir = ctx->local_path;
|
old_unix_dir = ctx->local_path;
|
||||||
ctx->local_path = talloc_strdup(ctx->mem_ctx, unix_dir);
|
ctx->local_path = talloc_strdup(ctx->mem_ctx, unix_dir);
|
||||||
|
|
||||||
pstrcpy(ctx->mask, nt_dir);
|
ctx->mask = talloc_asprintf(ctx->mem_ctx,
|
||||||
pstrcat(ctx->mask, "\\*");
|
"%s\\*",
|
||||||
|
nt_dir);
|
||||||
|
if (!ctx->local_path || !ctx->mask) {
|
||||||
|
DEBUG(0,("gpo_sync_func: ENOMEM\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!gpo_sync_files(ctx)) {
|
if (!gpo_sync_files(ctx)) {
|
||||||
DEBUG(0,("could not sync files\n"));
|
DEBUG(0,("could not sync files\n"));
|
||||||
}
|
}
|
||||||
@ -219,8 +223,12 @@ NTSTATUS gpo_sync_directories(TALLOC_CTX *mem_ctx,
|
|||||||
ctx.local_path = CONST_DISCARD(char *, local_path);
|
ctx.local_path = CONST_DISCARD(char *, local_path);
|
||||||
ctx.attribute = (aSYSTEM | aHIDDEN | aDIR);
|
ctx.attribute = (aSYSTEM | aHIDDEN | aDIR);
|
||||||
|
|
||||||
pstrcpy(ctx.mask, nt_path);
|
ctx.mask = talloc_asprintf(mem_ctx,
|
||||||
pstrcat(ctx.mask, "\\*");
|
"%s\\*",
|
||||||
|
nt_path);
|
||||||
|
if (!ctx.mask) {
|
||||||
|
return NT_STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
if (!gpo_sync_files(&ctx)) {
|
if (!gpo_sync_files(&ctx)) {
|
||||||
return NT_STATUS_NO_SUCH_FILE;
|
return NT_STATUS_NO_SUCH_FILE;
|
||||||
|
@ -444,11 +444,9 @@ static TDB_DATA locking_key(struct file_id id)
|
|||||||
Print out a share mode.
|
Print out a share mode.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
char *share_mode_str(int num, struct share_mode_entry *e)
|
char *share_mode_str(TALLOC_CTX *ctx, int num, struct share_mode_entry *e)
|
||||||
{
|
{
|
||||||
static pstring share_str;
|
return talloc_asprintf(ctx, "share_mode_entry[%d]: %s "
|
||||||
|
|
||||||
slprintf(share_str, sizeof(share_str)-1, "share_mode_entry[%d]: %s "
|
|
||||||
"pid = %s, share_access = 0x%x, private_options = 0x%x, "
|
"pid = %s, share_access = 0x%x, private_options = 0x%x, "
|
||||||
"access_mask = 0x%x, mid = 0x%x, type= 0x%x, gen_id = %lu, "
|
"access_mask = 0x%x, mid = 0x%x, type= 0x%x, gen_id = %lu, "
|
||||||
"uid = %u, flags = %u, file_id %s",
|
"uid = %u, flags = %u, file_id %s",
|
||||||
@ -459,8 +457,6 @@ char *share_mode_str(int num, struct share_mode_entry *e)
|
|||||||
e->access_mask, e->op_mid, e->op_type, e->share_file_id,
|
e->access_mask, e->op_mid, e->op_type, e->share_file_id,
|
||||||
(unsigned int)e->uid, (unsigned int)e->flags,
|
(unsigned int)e->uid, (unsigned int)e->flags,
|
||||||
file_id_string_tos(&e->id));
|
file_id_string_tos(&e->id));
|
||||||
|
|
||||||
return share_str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
@ -476,10 +472,12 @@ static void print_share_mode_table(struct locking_data *data)
|
|||||||
|
|
||||||
for (i = 0; i < num_share_modes; i++) {
|
for (i = 0; i < num_share_modes; i++) {
|
||||||
struct share_mode_entry entry;
|
struct share_mode_entry entry;
|
||||||
|
char *str = share_mode_str(NULL, i, &entry);
|
||||||
|
|
||||||
memcpy(&entry, &shares[i], sizeof(struct share_mode_entry));
|
memcpy(&entry, &shares[i], sizeof(struct share_mode_entry));
|
||||||
DEBUG(10,("print_share_mode_table: %s\n",
|
DEBUG(10,("print_share_mode_table: %s\n",
|
||||||
share_mode_str(i, &entry)));
|
str ? str : ""));
|
||||||
|
TALLOC_FREE(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -603,14 +601,16 @@ static bool parse_share_modes(TDB_DATA dbuf, struct share_mode_lock *lck)
|
|||||||
|
|
||||||
for (i = 0; i < lck->num_share_modes; i++) {
|
for (i = 0; i < lck->num_share_modes; i++) {
|
||||||
struct share_mode_entry *entry_p = &lck->share_modes[i];
|
struct share_mode_entry *entry_p = &lck->share_modes[i];
|
||||||
|
char *str = share_mode_str(NULL, i, entry_p);
|
||||||
DEBUG(10,("parse_share_modes: %s\n",
|
DEBUG(10,("parse_share_modes: %s\n",
|
||||||
share_mode_str(i, entry_p) ));
|
str ? str : ""));
|
||||||
if (!process_exists(entry_p->pid)) {
|
if (!process_exists(entry_p->pid)) {
|
||||||
DEBUG(10,("parse_share_modes: deleted %s\n",
|
DEBUG(10,("parse_share_modes: deleted %s\n",
|
||||||
share_mode_str(i, entry_p) ));
|
str ? str : ""));
|
||||||
entry_p->op_type = UNUSED_SHARE_MODE_ENTRY;
|
entry_p->op_type = UNUSED_SHARE_MODE_ENTRY;
|
||||||
lck->modified = True;
|
lck->modified = True;
|
||||||
}
|
}
|
||||||
|
TALLOC_FREE(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
|
@ -933,9 +933,12 @@ new: start=%.0f,size=%.0f\n", (double)l_curr->start, (double)l_curr->size,
|
|||||||
* This logic case should never happen. Ensure this is the
|
* This logic case should never happen. Ensure this is the
|
||||||
* case by forcing an abort.... Remove in production.
|
* case by forcing an abort.... Remove in production.
|
||||||
*/
|
*/
|
||||||
pstring msg;
|
char *msg = NULL;
|
||||||
|
|
||||||
slprintf(msg, sizeof(msg)-1, "logic flaw in cases: l_curr: start = %.0f, size = %.0f : \
|
/* Don't check if alloc succeeds here - we're
|
||||||
|
* forcing a core dump anyway. */
|
||||||
|
|
||||||
|
asprintf(&msg, "logic flaw in cases: l_curr: start = %.0f, size = %.0f : \
|
||||||
lock: start = %.0f, size = %.0f", (double)l_curr->start, (double)l_curr->size, (double)lock->start, (double)lock->size );
|
lock: start = %.0f, size = %.0f", (double)l_curr->start, (double)l_curr->size, (double)lock->start, (double)lock->size );
|
||||||
|
|
||||||
smb_panic(msg);
|
smb_panic(msg);
|
||||||
|
@ -521,7 +521,7 @@ static void validate_my_share_entries(int num,
|
|||||||
char *str = talloc_asprintf(talloc_tos(),
|
char *str = talloc_asprintf(talloc_tos(),
|
||||||
"Got a deferred entry without a request: "
|
"Got a deferred entry without a request: "
|
||||||
"PANIC: %s\n",
|
"PANIC: %s\n",
|
||||||
share_mode_str(num, share_entry));
|
share_mode_str(talloc_tos(), num, share_entry));
|
||||||
smb_panic(str);
|
smb_panic(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,7 +533,7 @@ static void validate_my_share_entries(int num,
|
|||||||
share_entry->share_file_id);
|
share_entry->share_file_id);
|
||||||
if (!fsp) {
|
if (!fsp) {
|
||||||
DEBUG(0,("validate_my_share_entries: PANIC : %s\n",
|
DEBUG(0,("validate_my_share_entries: PANIC : %s\n",
|
||||||
share_mode_str(num, share_entry) ));
|
share_mode_str(talloc_tos(), num, share_entry) ));
|
||||||
smb_panic("validate_my_share_entries: Cannot match a "
|
smb_panic("validate_my_share_entries: Cannot match a "
|
||||||
"share entry with an open file\n");
|
"share entry with an open file\n");
|
||||||
}
|
}
|
||||||
@ -560,7 +560,7 @@ static void validate_my_share_entries(int num,
|
|||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
DEBUG(0,("validate_my_share_entries: PANIC : %s\n",
|
DEBUG(0,("validate_my_share_entries: PANIC : %s\n",
|
||||||
share_mode_str(num, share_entry) ));
|
share_mode_str(talloc_tos(), num, share_entry) ));
|
||||||
str = talloc_asprintf(talloc_tos(),
|
str = talloc_asprintf(talloc_tos(),
|
||||||
"validate_my_share_entries: "
|
"validate_my_share_entries: "
|
||||||
"file %s, oplock_type = 0x%x, op_type = 0x%x\n",
|
"file %s, oplock_type = 0x%x, op_type = 0x%x\n",
|
||||||
|
@ -99,7 +99,7 @@ static int net_lookup_ldap(int argc, const char **argv)
|
|||||||
TALLOC_CTX *ctx;
|
TALLOC_CTX *ctx;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
int ret;
|
int ret;
|
||||||
char h_name[HOST_NAME_MAX];
|
char h_name[MAX_DNS_NAME_LENGTH];
|
||||||
|
|
||||||
if (argc > 0)
|
if (argc > 0)
|
||||||
domain = argv[0];
|
domain = argv[0];
|
||||||
|
@ -197,7 +197,7 @@ static bool query_one(const char *lookup, unsigned int lookup_type)
|
|||||||
for (j=0;j<count;j++) {
|
for (j=0;j<count;j++) {
|
||||||
char addr[INET6_ADDRSTRLEN];
|
char addr[INET6_ADDRSTRLEN];
|
||||||
if (translate_addresses) {
|
if (translate_addresses) {
|
||||||
char h_name[HOST_NAME_MAX];
|
char h_name[MAX_DNS_NAME_LENGTH];
|
||||||
h_name[0] = '\0';
|
h_name[0] = '\0';
|
||||||
if (sys_getnameinfo((const struct sockaddr *)&ip_list[j],
|
if (sys_getnameinfo((const struct sockaddr *)&ip_list[j],
|
||||||
sizeof(struct sockaddr_storage),
|
sizeof(struct sockaddr_storage),
|
||||||
|
Loading…
Reference in New Issue
Block a user