summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/charcnv.c175
-rw-r--r--source3/lib/hash.c16
-rw-r--r--source3/lib/pidfile.c2
-rw-r--r--source3/lib/time.c2
-rw-r--r--source3/lib/util.c35
-rw-r--r--source3/lib/util_file.c7
-rw-r--r--source3/lib/util_seaccess.c2
-rw-r--r--source3/lib/util_str.c251
-rw-r--r--source3/lib/util_unistr.c13
-rw-r--r--source3/lib/xfile.c7
-rw-r--r--source3/passdb/passdb.c11
-rw-r--r--source3/smbd/dosmode.c2
-rw-r--r--source3/smbd/mangle_hash2.c8
13 files changed, 284 insertions, 247 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index 4ac10a2e74..bffa2a378c 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -22,27 +22,22 @@
*/
#include "includes.h"
-/**
- * @file
- *
- * @brief Character-set conversion routines built on our iconv.
- *
- * @note Samba's internal character set (at least in the 3.0 series)
- * is always the same as the one for the Unix filesystem. It is
- * <b>not</b> necessarily UTF-8 and may be different on machines that
- * need i18n filenames to be compatible with Unix software. It does
- * have to be a superset of ASCII. All multibyte sequences must start
- * with a byte with the high bit set.
- */
-
static pstring cvtbuf;
static smb_iconv_t conv_handles[NUM_CHARSETS][NUM_CHARSETS];
-/****************************************************************************
- Return the name of a charset to give to iconv().
-****************************************************************************/
+/**
+ * @file
+ *
+ * Character set conversion routines.
+ *
+ * @sa lib/iconv.c
+ **/
+
+/**
+ * Return the name of a charset to give to iconv().
+ **/
static const char *charset_name(charset_t ch)
{
const char *ret = NULL;
@@ -69,9 +64,9 @@ static void lazy_initialize_conv(void)
}
}
-/****************************************************************************
+/**
Initialize iconv conversion descriptors.
-****************************************************************************/
+**/
void init_iconv(void)
{
@@ -117,14 +112,12 @@ void init_iconv(void)
/**
* Convert string from one encoding to another, making error checking etc
*
- * @param descriptor conversion descriptor, created in init_iconv()
* @param src pointer to source string (multibyte or singlebyte)
* @param srclen length of the source string in bytes
* @param dest pointer to destination string (multibyte or singlebyte)
* @param destlen maximal length allowed for string
- * @retval the number of bytes occupied in the destination
+ * @returns the number of bytes occupied in the destination
**/
-
size_t convert_string(charset_t from, charset_t to,
void const *src, size_t srclen,
void *dest, size_t destlen)
@@ -183,7 +176,7 @@ size_t convert_string(charset_t from, charset_t to,
* @param dest always set at least to NULL
* @note -1 is not accepted for srclen.
*
- * @retval Size in bytes of the converted string; or -1 in case of error.
+ * @returns Size in bytes of the converted string; or -1 in case of error.
**/
size_t convert_string_allocate(charset_t from, charset_t to,
@@ -255,6 +248,7 @@ convert:
return destlen;
}
+
/**
* Convert between character sets, allocating a new buffer using talloc for the result.
*
@@ -262,9 +256,8 @@ convert:
* @param dest always set at least to NULL
* @note -1 is not accepted for srclen.
*
- * @retval Size in bytes of the converted string; or -1 in case of error.
+ * @returns Size in bytes of the converted string; or -1 in case of error.
**/
-
size_t convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to,
void const *src, size_t srclen, void **dest)
{
@@ -311,16 +304,20 @@ size_t ucs2_align(const void *base_ptr, const void *p, int flags)
}
-/****************************************************************************
-copy a string from a char* unix src to a dos codepage string destination
-return the number of bytes occupied by the string in the destination
-flags can have:
- STR_TERMINATE means include the null termination
- STR_UPPER means uppercase in the destination
-dest_len is the maximum length in bytes allowed in the destination. If dest_len
-is -1 then no maxiumum is used
-****************************************************************************/
-
+/**
+ * Copy a string from a char* unix src to a dos codepage string destination.
+ *
+ * @return the number of bytes occupied by the string in the destination.
+ *
+ * @param flags can include
+ * <dl>
+ * <dt>STR_TERMINATE</dt> <dd>means include the null termination</dd>
+ * <dt>STR_UPPER</dt> <dd>means uppercase in the destination</dd>
+ * </dl>
+ *
+ * @param dest_len the maximum length in bytes allowed in the
+ * destination. If @p dest_len is -1 then no maximum is used.
+ **/
size_t push_ascii(void *dest, const char *src, size_t dest_len, int flags)
{
size_t src_len = strlen(src);
@@ -357,16 +354,21 @@ size_t push_pstring(void *dest, const char *src)
return push_ascii(dest, src, sizeof(pstring), STR_TERMINATE);
}
-/****************************************************************************
- Copy a string from a dos codepage source to a unix char* destination.
- Flags can have:
- STR_TERMINATE means the string in src is null terminated.
- if STR_TERMINATE is set then src_len is ignored.
- src_len is the length of the source area in bytes.
- Return the number of bytes occupied by the string in src.
- The resulting string in "dest" is always null terminated.
-****************************************************************************/
-
+/**
+ * Copy a string from a dos codepage source to a unix char* destination.
+ *
+ * The resulting string in "dest" is always null terminated.
+ *
+ * @param flags can have:
+ * <dl>
+ * <dt>STR_TERMINATE</dt>
+ * <dd>STR_TERMINATE means the string in @p src
+ * is null terminated, and src_len is ignored.</dd>
+ * </dl>
+ *
+ * @param src_len is the length of the source area in bytes.
+ * @returns the number of bytes occupied by the string in @p src.
+ **/
size_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len, int flags)
{
size_t ret;
@@ -403,17 +405,22 @@ size_t pull_ascii_fstring(char *dest, const void *src)
return pull_ascii(dest, src, sizeof(fstring), -1, STR_TERMINATE);
}
-/****************************************************************************
- Copy a string from a char* src to a unicode destination.
- Return the number of bytes occupied by the string in the destination.
- Flags can have:
- STR_TERMINATE means include the null termination.
- STR_UPPER means uppercase in the destination.
- STR_NOALIGN means don't do alignment.
- dest_len is the maximum length allowed in the destination. If dest_len
- is -1 then no maxiumum is used.
-****************************************************************************/
-
+/**
+ * Copy a string from a char* src to a unicode destination.
+ *
+ * @returns the number of bytes occupied by the string in the destination.
+ *
+ * @param flags can have:
+ *
+ * <dl>
+ * <dt>STR_TERMINATE <dd>means include the null termination.
+ * <dt>STR_UPPER <dd>means uppercase in the destination.
+ * <dt>STR_NOALIGN <dd>means don't do alignment.
+ * </dl>
+ *
+ * @param dest_len is the maximum length allowed in the
+ * destination. If dest_len is -1 then no maxiumum is used.
+ **/
size_t push_ucs2(const void *base_ptr, void *dest, const char *src, size_t dest_len, int flags)
{
size_t len=0;
@@ -447,15 +454,16 @@ size_t push_ucs2(const void *base_ptr, void *dest, const char *src, size_t dest_
return len;
}
+
/**
- * Copy a string from a unix char* src to a UCS2 destination, allocating a buffer using talloc
+ * Copy a string from a unix char* src to a UCS2 destination,
+ * allocating a buffer using talloc().
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
* or -1 in case of error.
**/
-
size_t push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src)
{
size_t src_len = strlen(src)+1;
@@ -464,12 +472,13 @@ size_t push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src)
return convert_string_talloc(ctx, CH_UNIX, CH_UCS2, src, src_len, (void **)dest);
}
+
/**
* Copy a string from a unix char* src to a UCS2 destination, allocating a buffer
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
* or -1 in case of error.
**/
@@ -481,7 +490,7 @@ size_t push_ucs2_allocate(smb_ucs2_t **dest, const char *src)
return convert_string_allocate(CH_UNIX, CH_UCS2, src, src_len, (void **)dest);
}
-/****************************************************************************
+/**
Copy a string from a char* src to a UTF-8 destination.
Return the number of bytes occupied by the string in the destination
Flags can have:
@@ -489,7 +498,7 @@ size_t push_ucs2_allocate(smb_ucs2_t **dest, const char *src)
STR_UPPER means uppercase in the destination
dest_len is the maximum length allowed in the destination. If dest_len
is -1 then no maxiumum is used.
-****************************************************************************/
+**/
size_t push_utf8(void *dest, const char *src, size_t dest_len, int flags)
{
@@ -527,7 +536,7 @@ size_t push_utf8_pstring(void *dest, const char *src)
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
**/
size_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
@@ -543,7 +552,7 @@ size_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
**/
size_t push_utf8_allocate(char **dest, const char *src)
@@ -554,7 +563,7 @@ size_t push_utf8_allocate(char **dest, const char *src)
return convert_string_allocate(CH_UNIX, CH_UTF8, src, src_len, (void **)dest);
}
-/****************************************************************************
+/**
Copy a string from a ucs2 source to a unix char* destination.
Flags can have:
STR_TERMINATE means the string in src is null terminated.
@@ -563,7 +572,7 @@ size_t push_utf8_allocate(char **dest, const char *src)
src_len is the length of the source area in bytes
Return the number of bytes occupied by the string in src.
The resulting string in "dest" is always null terminated.
-****************************************************************************/
+**/
size_t pull_ucs2(const void *base_ptr, char *dest, const void *src, size_t dest_len, size_t src_len, int flags)
{
@@ -615,7 +624,7 @@ size_t pull_ucs2_fstring(char *dest, const void *src)
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
**/
size_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src)
@@ -630,7 +639,7 @@ size_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src)
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
**/
size_t pull_ucs2_allocate(void **dest, const smb_ucs2_t *src)
@@ -640,7 +649,7 @@ size_t pull_ucs2_allocate(void **dest, const smb_ucs2_t *src)
return convert_string_allocate(CH_UCS2, CH_UNIX, src, src_len, dest);
}
-/****************************************************************************
+/**
Copy a string from a utf-8 source to a unix char* destination.
Flags can have:
STR_TERMINATE means the string in src is null terminated.
@@ -648,7 +657,7 @@ size_t pull_ucs2_allocate(void **dest, const smb_ucs2_t *src)
src_len is the length of the source area in bytes
Return the number of bytes occupied by the string in src.
The resulting string in "dest" is always null terminated.
-****************************************************************************/
+**/
size_t pull_utf8(char *dest, const void *src, size_t dest_len, size_t src_len, int flags)
{
@@ -690,7 +699,7 @@ size_t pull_utf8_fstring(char *dest, const void *src)
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
**/
size_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
@@ -705,7 +714,7 @@ size_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
*
* @param dest always set at least to NULL
*
- * @retval The number of bytes occupied by the string in the destination
+ * @returns The number of bytes occupied by the string in the destination
**/
size_t pull_utf8_allocate(void **dest, const char *src)
@@ -715,7 +724,7 @@ size_t pull_utf8_allocate(void **dest, const char *src)
return convert_string_allocate(CH_UTF8, CH_UNIX, src, src_len, dest);
}
-/****************************************************************************
+/**
Copy a string from a char* src to a unicode or ascii
dos codepage destination choosing unicode or ascii based on the
flags in the SMB buffer starting at base_ptr.
@@ -727,7 +736,7 @@ size_t pull_utf8_allocate(void **dest, const char *src)
STR_NOALIGN means don't do alignment.
dest_len is the maximum length allowed in the destination. If dest_len
is -1 then no maxiumum is used.
-****************************************************************************/
+**/
size_t push_string(const void *base_ptr, void *dest, const char *src, size_t dest_len, int flags)
{
@@ -740,7 +749,7 @@ size_t push_string(const void *base_ptr, void *dest, const char *src, size_t des
}
-/****************************************************************************
+/**
Copy a string from a unicode or ascii source (depending on
the packet flags) to a char* destination.
Flags can have:
@@ -752,7 +761,7 @@ size_t push_string(const void *base_ptr, void *dest, const char *src, size_t des
src_len is the length of the source area in bytes.
Return the number of bytes occupied by the string in src.
The resulting string in "dest" is always null terminated.
-****************************************************************************/
+**/
size_t pull_string(const void *base_ptr, char *dest, const void *src, size_t dest_len, size_t src_len, int flags)
{
@@ -774,12 +783,12 @@ size_t align_string(const void *base_ptr, const char *p, int flags)
return 0;
}
-/****************************************************************************
+/**
Convert from ucs2 to unix charset and return the
allocated and converted string or NULL if an error occurred.
You must provide a zero terminated string.
The returning string will be zero terminated.
-****************************************************************************/
+**/
char *acnv_u2ux(const smb_ucs2_t *src)
{
@@ -795,12 +804,12 @@ char *acnv_u2ux(const smb_ucs2_t *src)
return dest;
}
-/****************************************************************************
+/**
Convert from unix to ucs2 charset and return the
allocated and converted string or NULL if an error occurred.
You must provide a zero terminated string.
The returning string will be zero terminated.
-****************************************************************************/
+**/
smb_ucs2_t *acnv_uxu2(const char *src)
{
@@ -816,12 +825,12 @@ smb_ucs2_t *acnv_uxu2(const char *src)
return dest;
}
-/****************************************************************************
+/**
Convert from ucs2 to dos charset and return the
allocated and converted string or NULL if an error occurred.
You must provide a zero terminated string.
The returning string will be zero terminated.
-****************************************************************************/
+**/
char *acnv_u2dos(const smb_ucs2_t *src)
{
@@ -837,12 +846,12 @@ char *acnv_u2dos(const smb_ucs2_t *src)
return dest;
}
-/****************************************************************************
+/**
Convert from dos to ucs2 charset and return the
allocated and converted string or NULL if an error occurred.
You must provide a zero terminated string.
The returning string will be zero terminated.
-****************************************************************************/
+**/
smb_ucs2_t *acnv_dosu2(const char *src)
{
diff --git a/source3/lib/hash.c b/source3/lib/hash.c
index 6b7a8476b1..c7b1493b4c 100644
--- a/source3/lib/hash.c
+++ b/source3/lib/hash.c
@@ -28,7 +28,7 @@
#include "includes.h"
static BOOL enlarge_hash_table(hash_table *table);
-static int primes[] =
+static unsigned primes[] =
{17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209, 16411};
/****************************************************************************
@@ -47,9 +47,9 @@ static int primes[] =
****************************************************************************
*/
-BOOL hash_table_init(hash_table *table, int num_buckets, compare_function compare_func)
+BOOL hash_table_init(hash_table *table, unsigned num_buckets, compare_function compare_func)
{
- int i;
+ unsigned i;
ubi_dlList *bucket;
table->num_elements = 0;
@@ -118,7 +118,7 @@ static hash_element *hash_chain_find(hash_table *table, ubi_dlList *hash_chain,
{
hash_element *hash_elem;
ubi_dlNodePtr lru_item;
- int i = 0;
+ unsigned int i = 0;
for (hash_elem = (hash_element *)(ubi_dlFirst(hash_chain)); i < hash_chain->count;
i++, hash_elem = (hash_element *)(ubi_dlNext(hash_elem))) {
@@ -171,6 +171,7 @@ hash_element *hash_insert(hash_table *table, char *value, char *key)
hash_element *hash_elem;
ubi_dlNodePtr lru_item;
ubi_dlList *bucket;
+ size_t string_length;
/*
* If the hash table size has not reached the MAX_HASH_TABLE_SIZE,
@@ -204,12 +205,13 @@ hash_element *hash_insert(hash_table *table, char *value, char *key)
* string.
*/
- if(!(hash_elem = (hash_element *) malloc(sizeof(hash_element) + strlen(key)))) {
+ string_length = strlen(key);
+ if(!(hash_elem = (hash_element *) malloc(sizeof(hash_element) + string_length))) {
DEBUG(0,("hash_insert: malloc fail !\n"));
return (hash_element *)NULL;
}
- safe_strcpy((char *) hash_elem->key, key, strlen(key)+1);
+ safe_strcpy((char *) hash_elem->key, key, string_length);
hash_elem->value = (char *)value;
hash_elem->bucket = bucket;
@@ -299,7 +301,7 @@ static BOOL enlarge_hash_table(hash_table *table)
void hash_clear(hash_table *table)
{
- int i;
+ unsigned int i;
ubi_dlList *bucket = table->buckets;
hash_element *hash_elem;
for (i = 0; i < table->size; bucket++, i++) {
diff --git a/source3/lib/pidfile.c b/source3/lib/pidfile.c
index 16a12656b3..1a462bf128 100644
--- a/source3/lib/pidfile.c
+++ b/source3/lib/pidfile.c
@@ -100,7 +100,7 @@ void pidfile_create(const char *name)
memset(buf, 0, sizeof(buf));
slprintf(buf, sizeof(buf) - 1, "%u\n", (unsigned int) sys_getpid());
- if (write(fd, buf, strlen(buf)) != strlen(buf)) {
+ if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) {
DEBUG(0,("ERROR: can't write to file %s: %s\n",
pidFile, strerror(errno)));
exit(1);
diff --git a/source3/lib/time.c b/source3/lib/time.c
index ea5c6837bf..f76a1bdc0d 100644
--- a/source3/lib/time.c
+++ b/source3/lib/time.c
@@ -479,7 +479,7 @@ check if it's a null mtime
****************************************************************************/
BOOL null_mtime(time_t mtime)
{
- if (mtime == 0 || mtime == 0xFFFFFFFF || mtime == (time_t)-1)
+ if (mtime == 0 || mtime == (time_t)0xFFFFFFFF || mtime == (time_t)-1)
return(True);
return(False);
}
diff --git a/source3/lib/util.c b/source3/lib/util.c
index b4d9e9f16f..3958600cbd 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -249,13 +249,7 @@ BOOL init_names(void)
int n;
if (global_myname() == NULL || *global_myname() == '\0') {
- fstring name;
-
- fstrcpy( name, myhostname() );
- p = strchr( name, '.' );
- if (p)
- *p = 0;
- if (!set_global_myname(name)) {
+ if (!set_global_myname(myhostname())) {
DEBUG( 0, ( "init_structs: malloc fail.\n" ) );
return False;
}
@@ -315,9 +309,9 @@ BOOL in_group(gid_t group, gid_t current_gid, int ngroups, const gid_t *groups)
Like atoi but gets the value up to the separator character.
****************************************************************************/
-static char *Atoic(char *p, int *n, char *c)
+static const char *Atoic(const char *p, int *n, const char *c)
{
- if (!isdigit((int)*p)) {
+ if (!isdigit((const int)*p)) {
DEBUG(5, ("Atoic: malformed number\n"));
return NULL;
}
@@ -339,7 +333,7 @@ static char *Atoic(char *p, int *n, char *c)
Reads a list of numbers.
*************************************************************************/
-char *get_numlist(char *p, uint32 **num, int *count)
+const char *get_numlist(const char *p, uint32 **num, int *count)
{
int val;
@@ -1014,7 +1008,7 @@ BOOL get_myfullname(char *my_name)
Get my own domain name.
****************************************************************************/
-BOOL get_mydomname(char *my_domname)
+BOOL get_mydomname(fstring my_domname)
{
pstring hostname;
char *p;
@@ -1730,6 +1724,23 @@ BOOL is_myname_or_ipaddr(const char *s)
}
/*******************************************************************
+ Is the name specified our workgroup/domain.
+ Returns true if it is equal, false otherwise.
+********************************************************************/
+
+BOOL is_myworkgroup(const char *s)
+{
+ BOOL ret = False;
+
+ if (strequal(s, lp_workgroup())) {
+ ret=True;
+ }
+
+ DEBUG(8, ("is_myworkgroup(\"%s\") returns %d\n", s, ret));
+ return(ret);
+}
+
+/*******************************************************************
Set the horrid remote_arch string based on an enum.
********************************************************************/
@@ -2389,7 +2400,7 @@ static BOOL unix_do_match(char *regexp, char *str)
Simple case insensitive interface to a UNIX wildcard matcher.
*******************************************************************/
-BOOL unix_wild_match(char *pattern, char *string)
+BOOL unix_wild_match(const char *pattern, const char *string)
{
pstring p2, s2;
char *p;
diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c
index 611e0e40be..02acbd4d7e 100644
--- a/source3/lib/util_file.c
+++ b/source3/lib/util_file.c
@@ -362,7 +362,7 @@ char *file_pload(char *syscmd, size_t *size)
while ((n = read(fd, buf, sizeof(buf))) > 0) {
tp = Realloc(p, total + n + 1);
if (!tp) {
- DEBUG(0,("file_pload: failed to exand buffer!\n"));
+ DEBUG(0,("file_pload: failed to expand buffer!\n"));
close(fd);
SAFE_FREE(p);
return NULL;
@@ -372,6 +372,9 @@ char *file_pload(char *syscmd, size_t *size)
}
if (p) p[total] = 0;
+ /* FIXME: Perhaps ought to check that the command completed
+ * successfully (returned 0); if not the data may be
+ * truncated. */
sys_pclose(fd);
if (size) *size = total;
@@ -590,7 +593,7 @@ BOOL file_save(const char *fname, void *packet, size_t length)
if (fd == -1) {
return False;
}
- if (write(fd, packet, length) != length) {
+ if (write(fd, packet, length) != (size_t)length) {
return False;
}
close(fd);
diff --git a/source3/lib/util_seaccess.c b/source3/lib/util_seaccess.c
index 21d7fe8599..eba8cab7fb 100644
--- a/source3/lib/util_seaccess.c
+++ b/source3/lib/util_seaccess.c
@@ -343,7 +343,7 @@ SEC_DESC_BUF *se_create_child_secdesc(TALLOC_CTX *ctx, SEC_DESC *parent_ctr,
SEC_DESC *sd;
SEC_ACL *new_dacl, *the_acl;
SEC_ACE *new_ace_list = NULL;
- int new_ace_list_ndx = 0, i;
+ unsigned int new_ace_list_ndx = 0, i;
size_t size;
/* Currently we only process the dacl when creating the child. The
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 21361a1862..cc4b6fe5c5 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -21,13 +21,13 @@
#include "includes.h"
-/****************************************************************************
- Get the next token from a string, return False if none found.
- Handles double-quotes.
- Based on a routine by GJC@VILLAGE.COM.
- Extensively modified by Andrew.Tridgell@anu.edu.au
-****************************************************************************/
-
+/**
+ * Get the next token from a string, return False if none found.
+ * Handles double-quotes.
+ *
+ * Based on a routine by GJC@VILLAGE.COM.
+ * Extensively modified by Andrew.Tridgell@anu.edu.au
+ **/
BOOL next_token(const char **ptr,char *buff, const char *sep, size_t bufsize)
{
const char *s;
@@ -67,11 +67,11 @@ BOOL next_token(const char **ptr,char *buff, const char *sep, size_t bufsize)
return(True);
}
-/****************************************************************************
+/**
This is like next_token but is not re-entrant and "remembers" the first
parameter so you can pass NULL. This is useful for user interface code
but beware the fact that it is not re-entrant!
-****************************************************************************/
+**/
static char *last_ptr=NULL;
@@ -93,10 +93,10 @@ void set_first_token(char *ptr)
last_ptr = ptr;
}
-/****************************************************************************
+/**
Convert list of tokens to array; dependent on above routine.
Uses last_ptr from above - bit of a hack.
-****************************************************************************/
+**/
char **toktocliplist(int *ctok, const char *sep)
{
@@ -139,9 +139,9 @@ char **toktocliplist(int *ctok, const char *sep)
return ret;
}
-/*******************************************************************
+/**
Case insensitive string compararison.
-********************************************************************/
+**/
int StrCaseCmp(const char *s, const char *t)
{
@@ -151,9 +151,9 @@ int StrCaseCmp(const char *s, const char *t)
return strcmp(buf1,buf2);
}
-/*******************************************************************
+/**
Case insensitive string compararison, length limited.
-********************************************************************/
+**/
int StrnCaseCmp(const char *s, const char *t, size_t n)
{
@@ -163,9 +163,9 @@ int StrnCaseCmp(const char *s, const char *t, size_t n)
return strncmp(buf1,buf2,n);
}
-/*******************************************************************
+/**
Compare 2 strings.
-********************************************************************/
+**/
BOOL strequal(const char *s1, const char *s2)
{
@@ -177,9 +177,9 @@ BOOL strequal(const char *s1, const char *s2)
return(StrCaseCmp(s1,s2)==0);
}
-/*******************************************************************
+/**
Compare 2 strings up to and including the nth char.
-******************************************************************/
+**/
BOOL strnequal(const char *s1,const char *s2,size_t n)
{
@@ -191,9 +191,9 @@ BOOL strnequal(const char *s1,const char *s2,size_t n)
return(StrnCaseCmp(s1,s2,n)==0);
}
-/*******************************************************************
+/**
Compare 2 strings (case sensitive).
-********************************************************************/
+**/
BOOL strcsequal(const char *s1,const char *s2)
{
@@ -205,9 +205,9 @@ BOOL strcsequal(const char *s1,const char *s2)
return(strcmp(s1,s2)==0);
}
-/***************************************************************************
+/**
Do a case-insensitive, whitespace-ignoring string compare.
-***************************************************************************/
+**/
int strwicmp(const char *psz1, const char *psz2)
{
@@ -236,9 +236,9 @@ int strwicmp(const char *psz1, const char *psz2)
}
-/*******************************************************************
+/**
Convert a string to upper case, but don't modify it.
-********************************************************************/
+**/
char *strupper_static(const char *s)
{
@@ -250,9 +250,9 @@ char *strupper_static(const char *s)
return str;
}
-/*******************************************************************
+/**
Convert a string to "normal" form.
-********************************************************************/
+**/
void strnorm(char *s)
{
@@ -263,9 +263,9 @@ void strnorm(char *s)
strlower(s);
}
-/*******************************************************************
+/**
Check if a string is in "normal" case.
-********************************************************************/
+**/
BOOL strisnormal(const char *s)
{
@@ -277,10 +277,10 @@ BOOL strisnormal(const char *s)
}
-/****************************************************************************
+/**
String replace.
NOTE: oldc and newc must be 7 bit characters
-****************************************************************************/
+**/
void string_replace(char *s,char oldc,char newc)
{
@@ -289,9 +289,9 @@ void string_replace(char *s,char oldc,char newc)
pull_ucs2(NULL, s, tmpbuf, -1, sizeof(tmpbuf), STR_TERMINATE);
}
-/*******************************************************************
+/**
Skip past some strings in a buffer.
-********************************************************************/
+**/
char *skip_string(char *buf,size_t n)
{
@@ -300,11 +300,11 @@ char *skip_string(char *buf,size_t n)
return(buf);
}
-/*******************************************************************
+/**
Count the number of characters in a string. Normally this will
be the same as the number of bytes in a string for single byte strings,
but will be different for multibyte.
-********************************************************************/
+**/
size_t str_charnum(const char *s)
{
@@ -313,11 +313,11 @@ size_t str_charnum(const char *s)
return strlen_w(tmpbuf2);
}
-/*******************************************************************
+/**
Count the number of characters in a string. Normally this will
be the same as the number of bytes in a string for single byte strings,
but will be different for multibyte.
-********************************************************************/
+**/
size_t str_ascii_charnum(const char *s)
{
@@ -326,9 +326,9 @@ size_t str_ascii_charnum(const char *s)
return strlen(tmpbuf2);
}
-/*******************************************************************
+/**
Trim the specified elements off the front and back of a string.
-********************************************************************/
+**/
BOOL trim_string(char *s,const char *front,const char *back)
{
@@ -364,9 +364,9 @@ BOOL trim_string(char *s,const char *front,const char *back)
return ret;
}
-/****************************************************************************
+/**
Does a string have any uppercase chars in it?
-****************************************************************************/
+**/
BOOL strhasupper(const char *s)
{
@@ -378,9 +378,9 @@ BOOL strhasupper(const char *s)
return(False);
}
-/****************************************************************************
+/**
Does a string have any lowercase chars in it?
-****************************************************************************/
+**/
BOOL strhaslower(const char *s)
{
@@ -392,9 +392,9 @@ BOOL strhaslower(const char *s)
return(False);
}
-/****************************************************************************
+/**
Find the number of 'c' chars in a string
-****************************************************************************/
+**/
size_t count_chars(const char *s,char c)
{
@@ -407,9 +407,9 @@ size_t count_chars(const char *s,char c)
return(count);
}
-/*******************************************************************
+/**
Return True if a string consists only of one particular character.
-********************************************************************/
+**/
BOOL str_is_all(const char *s,char c)
{
@@ -428,10 +428,10 @@ BOOL str_is_all(const char *s,char c)
return True;
}
-/*******************************************************************
+/**
Safe string copy into a known length string. maxlength does not
include the terminating zero.
-********************************************************************/
+**/
char *safe_strcpy(char *dest,const char *src, size_t maxlength)
{
@@ -442,6 +442,14 @@ char *safe_strcpy(char *dest,const char *src, size_t maxlength)
return NULL;
}
+#ifdef DEVELOPER
+ /* We intentionally write out at the extremity of the destination
+ * string. If the destination is too short (e.g. pstrcpy into mallocd
+ * or fstring) then this should cause an error under a memory
+ * checker. */
+ dest[maxlength] = '\0';
+#endif
+
if (!src) {
*dest = 0;
return dest;
@@ -450,8 +458,8 @@ char *safe_strcpy(char *dest,const char *src, size_t maxlength)
len = strlen(src);
if (len > maxlength) {
- DEBUG(0,("ERROR: string overflow by %d in safe_strcpy [%.50s]\n",
- (int)(len-maxlength), src));
+ DEBUG(0,("ERROR: string overflow by %u (%u - %u) in safe_strcpy [%.50s]\n",
+ (unsigned int)(len-maxlength), len, maxlength, src));
len = maxlength;
}
@@ -460,10 +468,10 @@ char *safe_strcpy(char *dest,const char *src, size_t maxlength)
return dest;
}
-/*******************************************************************
+/**
Safe string cat into a string. maxlength does not
include the terminating zero.
-********************************************************************/
+**/
char *safe_strcat(char *dest, const char *src, size_t maxlength)
{
@@ -495,12 +503,12 @@ char *safe_strcat(char *dest, const char *src, size_t maxlength)
return dest;
}
-/*******************************************************************
+/**
Paranoid strcpy into a buffer of given length (includes terminating
zero. Strips out all but 'a-Z0-9' and the character in other_safe_chars
and replaces with '_'. Deliberately does *NOT* check for multibyte
characters. Don't change it !
-********************************************************************/
+**/
char *alpha_strcpy(char *dest, const char *src, const char *other_safe_chars, size_t maxlength)
{
@@ -536,10 +544,10 @@ char *alpha_strcpy(char *dest, const char *src, const char *other_safe_chars, si
return dest;
}
-/****************************************************************************
+/**
Like strncpy but always null terminates. Make sure there is room!
The variable n should always be one less than the available size.
-****************************************************************************/
+**/
char *StrnCpy(char *dest,const char *src,size_t n)
{
@@ -556,10 +564,10 @@ char *StrnCpy(char *dest,const char *src,size_t n)
return(dest);
}
-/****************************************************************************
+/**
Like strncpy but copies up to the character marker. always null terminates.
returns a pointer to the character marker in the source string (src).
-****************************************************************************/
+**/
char *strncpyn(char *dest, const char *src, size_t n, char c)
{
@@ -579,7 +587,7 @@ char *strncpyn(char *dest, const char *src, size_t n, char c)
return p;
}
-/*************************************************************
+/**
Routine to get hex characters and turn them into a 16 byte array.
the array can be variable length, and any non-hex-numeric
characters are skipped. "0xnn" or "0Xnn" is specially catered
@@ -587,7 +595,7 @@ char *strncpyn(char *dest, const char *src, size_t n, char c)
valid examples: "0A5D15"; "0x15, 0x49, 0xa2"; "59\ta9\te3\n"
-**************************************************************/
+**/
size_t strhex_to_str(char *p, size_t len, const char *strhex)
{
@@ -624,9 +632,9 @@ size_t strhex_to_str(char *p, size_t len, const char *strhex)
return num_chars;
}
-/****************************************************************************
+/**
Check if a string is part of a list.
-****************************************************************************/
+**/
BOOL in_list(char *s,char *list,BOOL casesensitive)
{
@@ -651,9 +659,9 @@ BOOL in_list(char *s,char *list,BOOL casesensitive)
/* this is used to prevent lots of mallocs of size 1 */
static char *null_string = NULL;
-/****************************************************************************
+/**
Set a string value, allocing the space for the string
-****************************************************************************/
+**/
static BOOL string_init(char **dest,const char *src)
{
@@ -682,9 +690,9 @@ static BOOL string_init(char **dest,const char *src)
return(True);
}
-/****************************************************************************
+/**
Free a string value.
-****************************************************************************/
+**/
void string_free(char **s)
{
@@ -695,10 +703,10 @@ void string_free(char **s)
SAFE_FREE(*s);
}
-/****************************************************************************
+/**
Set a string value, deallocating any existing space, and allocing the space
for the string
-****************************************************************************/
+**/
BOOL string_set(char **dest,const char *src)
{
@@ -706,7 +714,7 @@ BOOL string_set(char **dest,const char *src)
return(string_init(dest,src));
}
-/****************************************************************************
+/**
Substitute a string for a pattern in another string. Make sure there is
enough room!
@@ -716,7 +724,7 @@ BOOL string_set(char **dest,const char *src)
Any of " ; ' $ or ` in the insert string are replaced with _
if len==0 then the string cannot be extended. This is different from the old
use of len==0 which was for no length checks to be done.
-****************************************************************************/
+**/
void string_sub(char *s,const char *pattern, const char *insert, size_t len)
{
@@ -774,12 +782,12 @@ void pstring_sub(char *s,const char *pattern,const char *insert)
string_sub(s, pattern, insert, sizeof(pstring));
}
-/****************************************************************************
+/**
Similar to string_sub, but it will accept only allocated strings
and may realloc them so pay attention at what you pass on no
pointers inside strings, no pstrings or const may be passed
as string.
-****************************************************************************/
+**/
char *realloc_string_sub(char *string, const char *pattern, const char *insert)
{
@@ -840,12 +848,12 @@ char *realloc_string_sub(char *string, const char *pattern, const char *insert)
return string;
}
-/****************************************************************************
+/**
Similar to string_sub() but allows for any character to be substituted.
Use with caution!
if len==0 then the string cannot be extended. This is different from the old
use of len==0 which was for no length checks to be done.
-****************************************************************************/
+**/
void all_string_sub(char *s,const char *pattern,const char *insert, size_t len)
{
@@ -881,12 +889,12 @@ void all_string_sub(char *s,const char *pattern,const char *insert, size_t len)
}
}
-/****************************************************************************
+/**
Similar to all_string_sub but for unicode strings.
Return a new allocated unicode string.
similar to string_sub() but allows for any character to be substituted.
Use with caution!
-****************************************************************************/
+**/
smb_ucs2_t *all_string_sub_w(const smb_ucs2_t *s, const smb_ucs2_t *pattern,
const smb_ucs2_t *insert)
@@ -946,9 +954,9 @@ smb_ucs2_t *all_string_sub_wa(smb_ucs2_t *s, const char *pattern,
return all_string_sub_w(s, p, i);
}
-/****************************************************************************
+/**
Splits out the front and back at a separator.
-****************************************************************************/
+**/
void split_at_last_component(char *path, char *front, char sep, char *back)
{
@@ -970,9 +978,9 @@ void split_at_last_component(char *path, char *front, char sep, char *back)
}
}
-/****************************************************************************
+/**
Write an octal as a string.
-****************************************************************************/
+**/
const char *octal_string(int i)
{
@@ -984,9 +992,9 @@ const char *octal_string(int i)
}
-/****************************************************************************
+/**
Truncate a string at a specified length.
-****************************************************************************/
+**/
char *string_truncate(char *s, int length)
{
@@ -995,10 +1003,10 @@ char *string_truncate(char *s, int length)
return s;
}
-/****************************************************************************
+/**
Strchr and strrchr_m are very hard to do on general multi-byte strings.
We convert via ucs2 for now.
-****************************************************************************/
+**/
char *strchr_m(const char *s, char c)
{
@@ -1030,9 +1038,9 @@ char *strrchr_m(const char *s, char c)
return (char *)(s+strlen(s2));
}
-/*******************************************************************
+/**
Convert a string to lower case.
-********************************************************************/
+**/
void strlower_m(char *s)
{
@@ -1054,9 +1062,9 @@ void strlower_m(char *s)
unix_strlower(s,strlen(s)+1,s,strlen(s)+1);
}
-/*******************************************************************
+/**
Duplicate convert a string to lower case.
-********************************************************************/
+**/
char *strdup_lower(const char *s)
{
@@ -1069,9 +1077,9 @@ char *strdup_lower(const char *s)
return t;
}
-/*******************************************************************
+/**
Convert a string to upper case.
-********************************************************************/
+**/
void strupper_m(char *s)
{
@@ -1093,9 +1101,9 @@ void strupper_m(char *s)
unix_strupper(s,strlen(s)+1,s,strlen(s)+1);
}
-/*******************************************************************
+/**
Convert a string to upper case.
-********************************************************************/
+**/
char *strdup_upper(const char *s)
{
@@ -1108,11 +1116,11 @@ char *strdup_upper(const char *s)
return t;
}
-/*******************************************************************
+/**
Return a RFC2254 binary string representation of a buffer.
Used in LDAP filters.
Caller must free.
-********************************************************************/
+**/
char *binary_string(char *buf, int len)
{
@@ -1132,9 +1140,9 @@ char *binary_string(char *buf, int len)
return s;
}
-/*******************************************************************
+/**
Just a typesafety wrapper for snprintf into a pstring.
-********************************************************************/
+**/
int pstr_sprintf(pstring s, const char *fmt, ...)
{
@@ -1147,9 +1155,9 @@ char *binary_string(char *buf, int len)
return ret;
}
-/*******************************************************************
+/**
Just a typesafety wrapper for snprintf into a fstring.
-********************************************************************/
+**/
int fstr_sprintf(fstring s, const char *fmt, ...)
{
@@ -1163,9 +1171,9 @@ char *binary_string(char *buf, int len)
}
#ifndef HAVE_STRNDUP
-/*******************************************************************
+/**
Some platforms don't have strndup.
-********************************************************************/
+**/
char *strndup(const char *s, size_t n)
{
@@ -1183,9 +1191,9 @@ char *binary_string(char *buf, int len)
#endif
#ifndef HAVE_STRNLEN
-/*******************************************************************
+/**
Some platforms don't have strnlen
-********************************************************************/
+**/
size_t strnlen(const char *s, size_t n)
{
@@ -1196,9 +1204,9 @@ char *binary_string(char *buf, int len)
}
#endif
-/***********************************************************
+/**
List of Strings manipulation functions
-***********************************************************/
+**/
#define S_LIST_ABS 16 /* List Allocation Block Size */
@@ -1291,10 +1299,9 @@ BOOL str_list_copy(char ***dest, const char **src)
return True;
}
-/***********************************************************
- Return true if all the elements of the list match exactly.
-***********************************************************/
-
+/**
+ * Return true if all the elements of the list match exactly.
+ **/
BOOL str_list_compare(char **list1, char **list2)
{
int num;
@@ -1499,9 +1506,9 @@ void ipstr_list_free(char* ipstr_list)
}
-/***********************************************************
+/**
Unescape a URL encoded string, in place.
-***********************************************************/
+**/
void rfc1738_unescape(char *buf)
{
@@ -1541,9 +1548,9 @@ void rfc1738_unescape(char *buf)
static const char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-/***************************************************************************
-decode a base64 string into a DATA_BLOB - simple and slow algorithm
- ***************************************************************************/
+/**
+ * Decode a base64 string into a DATA_BLOB - simple and slow algorithm
+ **/
DATA_BLOB base64_decode_data_blob(const char *s)
{
int bit_offset, byte_offset, idx, i, n;
@@ -1575,9 +1582,9 @@ DATA_BLOB base64_decode_data_blob(const char *s)
return decoded;
}
-/***************************************************************************
-decode a base64 string in-place - wrapper for the above
-***************************************************************************/
+/**
+ * Decode a base64 string in-place - wrapper for the above
+ **/
void base64_decode_inplace(char *s)
{
DATA_BLOB decoded = base64_decode_data_blob(s);
@@ -1588,11 +1595,11 @@ void base64_decode_inplace(char *s)
s[decoded.length] = '\0';
}
-/***************************************************************************
-encode a base64 string into a malloc()ed string caller to free.
-
-From SQUID: adopted from http://ftp.sunet.se/pub2/gnu/vm/base64-encode.c with adjustments
-***************************************************************************/
+/**
+ * Encode a base64 string into a malloc()ed string caller to free.
+ *
+ *From SQUID: adopted from http://ftp.sunet.se/pub2/gnu/vm/base64-encode.c with adjustments
+ **/
char * base64_encode_data_blob(DATA_BLOB data)
{
int bits = 0;
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c
index 5c9b4c783b..522ab7eb40 100644
--- a/source3/lib/util_unistr.c
+++ b/source3/lib/util_unistr.c
@@ -95,9 +95,14 @@ static int check_dos_char(smb_ucs2_t c)
return (c == c2);
}
-/*******************************************************************
-load the valid character map table
-********************************************************************/
+/**
+ * Load the valid character map table from <tt>valid.dat</tt> or
+ * create from the configured codepage.
+ *
+ * This function is called whenever the configuration is reloaded.
+ * However, the valid character table is not changed if it's loaded
+ * from a file, because we can't unmap files.
+ **/
void init_valid_table(void)
{
static int initialised;
@@ -114,6 +119,7 @@ void init_valid_table(void)
return;
}
+ /* Otherwise, using a dynamically loaded one. */
if (valid_table) free(valid_table);
DEBUG(2,("creating default valid table\n"));
@@ -128,6 +134,7 @@ void init_valid_table(void)
}
+
/*******************************************************************
Write a string in (little-endian) unicode format. src is in
the current DOS codepage. len is the length in bytes of the
diff --git a/source3/lib/xfile.c b/source3/lib/xfile.c
index 57f3e27638..1534dd855e 100644
--- a/source3/lib/xfile.c
+++ b/source3/lib/xfile.c
@@ -140,9 +140,10 @@ int x_fclose(XFILE *f)
}
/* simulate fwrite() */
-int x_fwrite(const void *p, size_t size, size_t nmemb, XFILE *f)
+size_t x_fwrite(const void *p, size_t size, size_t nmemb, XFILE *f)
{
- int ret, total=0;
+ ssize_t ret;
+ size_t total=0;
/* we might be writing unbuffered */
if (f->buftype == X_IONBF ||
@@ -154,7 +155,7 @@ int x_fwrite(const void *p, size_t size, size_t nmemb, XFILE *f)
while (total < size*nmemb) {
- int n = f->bufsize - f->bufused;
+ size_t n = f->bufsize - f->bufused;
n = MIN(n, (size*nmemb)-total);
if (n == 0) {
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index 71a880d295..5e6466ff0a 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -283,7 +283,7 @@ NTSTATUS pdb_init_sam_pw(SAM_ACCOUNT **new_sam_acct, const struct passwd *pwd)
if (!pwd) {
new_sam_acct = NULL;
- return NT_STATUS_UNSUCCESSFUL;
+ return NT_STATUS_INVALID_PARAMETER;
}
if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(new_sam_acct))) {
@@ -661,7 +661,7 @@ BOOL local_lookup_sid(DOM_SID *sid, char *name, enum SID_NAME_USE *psid_name_use
pdb_free_sam(&sam_account);
if (pdb_getgrsid(&map, *sid, MAPPING_WITHOUT_PRIV)) {
- if (map.gid!=-1) {
+ if (map.gid!=(gid_t)-1) {
DEBUG(5,("local_lookup_sid: mapped group %s to gid %u\n", map.nt_name, (unsigned int)map.gid));
} else {
DEBUG(5,("local_lookup_sid: mapped group %s to no unix gid. Returning name.\n", map.nt_name));
@@ -950,7 +950,7 @@ BOOL local_sid_to_gid(gid_t *pgid, const DOM_SID *psid, enum SID_NAME_USE *name_
if (pdb_getgrsid(&map, *psid, MAPPING_WITHOUT_PRIV)) {
/* the SID is in the mapping table but not mapped */
- if (map.gid==-1)
+ if (map.gid==(gid_t)-1)
return False;
*pgid = map.gid;
@@ -992,10 +992,7 @@ BOOL local_sid_to_gid(gid_t *pgid, const DOM_SID *psid, enum SID_NAME_USE *name_
/*************************************************************
Change a password entry in the local smbpasswd file.
- FIXME!! The function needs to be abstracted into the
- passdb interface or something. It is currently being called
- by _api_samr_create_user() in rpc_server/srv_samr.c,
- in SWAT and by smbpasswd/pdbedit.
+It is currently being called by SWAT and by smbpasswd.
--jerry
*************************************************************/
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index 77d8c9cc92..6c21dc04d0 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -181,7 +181,7 @@ uint32 dos_mode(connection_struct *conn,char *path,SMB_STRUCT_STAT *sbuf)
/*******************************************************************
chmod a file - but preserve some bits
********************************************************************/
-int file_chmod(connection_struct *conn,char *fname,int dosmode,SMB_STRUCT_STAT *st)
+int file_chmod(connection_struct *conn,char *fname, uint32 dosmode,SMB_STRUCT_STAT *st)
{
SMB_STRUCT_STAT st1;
int mask=0;
diff --git a/source3/smbd/mangle_hash2.c b/source3/smbd/mangle_hash2.c
index bbc9020eab..eda509214d 100644
--- a/source3/smbd/mangle_hash2.c
+++ b/source3/smbd/mangle_hash2.c
@@ -203,7 +203,7 @@ static const char *cache_lookup(u32 hash)
*/
static BOOL is_mangled_component(const char *name)
{
- int len, i;
+ unsigned int len, i;
M_DEBUG(10,("is_mangled_component %s ?\n", name));
@@ -368,7 +368,7 @@ static void mangle_reset(void)
static BOOL check_cache(char *name)
{
u32 hash, multiplier;
- int i;
+ unsigned int i;
const char *prefix;
char extension[4];
@@ -489,8 +489,8 @@ static void name_map(char *name, BOOL need83, BOOL cache83)
char *dot_p;
char lead_chars[7];
char extension[4];
- int extension_length, i;
- int prefix_len;
+ unsigned int extension_length, i;
+ unsigned int prefix_len;
u32 hash, v;
char new_name[13];