diff -u -r --new-file --exclude=CVS samba-3.0.2rc2/source/Makefile.in samba-3.0.2/source/Makefile.in --- samba-3.0.2rc2/source/Makefile.in Fri Jan 16 11:47:52 2004 +++ samba-3.0.2/source/Makefile.in Fri Feb 6 16:40:27 2004 @@ -1227,6 +1227,8 @@ @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(BIN_PROGS) +# Some symlinks are required for the 'probing' of modules. +# This mechanism should go at some point.. installmodules: modules installdirs @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(VFSLIBDIR) $(VFS_MODULES) @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(PDBLIBDIR) $(PDB_MODULES) @@ -1234,8 +1236,6 @@ @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(IDMAPLIBDIR) $(IDMAP_MODULES) @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(CHARSETLIBDIR) $(CHARSET_MODULES) @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(AUTHLIBDIR) $(AUTH_MODULES) - @# These symlinks are required for the 'probing' of modules. - @# This mechanism should go at some point.. @$(SHELL) $(srcdir)/script/linkmodules.sh $(DESTDIR)$(PDBLIBDIR) ldapsam.@SHLIBEXT@ ldapsam_compat.@SHLIBEXT@ @$(SHELL) $(srcdir)/script/linkmodules.sh $(DESTDIR)$(AUTHLIBDIR) rhosts.@SHLIBEXT@ hostsequiv.@SHLIBEXT@ @$(SHELL) $(srcdir)/script/linkmodules.sh $(DESTDIR)$(AUTHLIBDIR) sam.@SHLIBEXT@ sam_ignoredomain.@SHLIBEXT@ diff -u -r --new-file --exclude=CVS samba-3.0.2rc2/source/VERSION samba-3.0.2/source/VERSION --- samba-3.0.2rc2/source/VERSION Sat Jan 31 09:45:56 2004 +++ samba-3.0.2/source/VERSION Fri Feb 6 16:40:27 2004 @@ -51,7 +51,7 @@ # e.g. SAMBA_VERSION_RC_RELEASE=1 # # -> "3.0.0rc1" # ######################################################## -SAMBA_VERSION_RC_RELEASE=2 +SAMBA_VERSION_RC_RELEASE= ######################################################## # For 'beta' releases the version will be # diff -u -r --new-file --exclude=CVS samba-3.0.2rc2/source/include/version.h samba-3.0.2/source/include/version.h --- samba-3.0.2rc2/source/include/version.h Sat Jan 31 14:01:32 2004 +++ samba-3.0.2/source/include/version.h Fri Feb 6 16:44:44 2004 @@ -2,6 +2,5 @@ #define SAMBA_VERSION_MAJOR 3 #define SAMBA_VERSION_MINOR 0 #define SAMBA_VERSION_RELEASE 2 -#define SAMBA_VERSION_RC_RELEASE 2 -#define SAMBA_VERSION_OFFICIAL_STRING "3.0.2rc2" +#define SAMBA_VERSION_OFFICIAL_STRING "3.0.2" #define SAMBA_VERSION_STRING samba_version_string() diff -u -r --new-file --exclude=CVS samba-3.0.2rc2/source/lib/charcnv.c samba-3.0.2/source/lib/charcnv.c --- samba-3.0.2rc2/source/lib/charcnv.c Fri Jan 16 11:47:52 2004 +++ samba-3.0.2/source/lib/charcnv.c Fri Feb 6 16:40:29 2004 @@ -184,14 +184,18 @@ } } + if (descriptor == (smb_iconv_t)-1 || descriptor == (smb_iconv_t)0) { if (!conv_silent) DEBUG(0,("convert_string_internal: Conversion not supported.\n")); - goto use_as_is; + return 0; } i_len=srclen; o_len=destlen; + + again: + retval = smb_iconv(descriptor, (char **)&inbuf, &i_len, &outbuf, &o_len); if(retval==(size_t)-1) { const char *reason="unknown error"; @@ -227,12 +231,77 @@ use_as_is: - /* conversion not supported, use as is */ + /* + * Conversion not supported. This is actually an error, but there are so + * many misconfigured iconv systems and smb.conf's out there we can't just + * fail. Do a very bad conversion instead.... JRA. + */ + { - size_t len = MIN(srclen,destlen); - if (len) - memcpy(dest,src,len); - return len; + if (o_len == 0 || i_len == 0) + return destlen - o_len; + + if (from == CH_UCS2 && to != CH_UCS2) { + /* Can't convert from ucs2 to multibyte. Just truncate this char to ascii. */ + if (i_len < 2) + return destlen - o_len; + if (i_len >= 2) { + *outbuf = inbuf[0]; + + outbuf++; + o_len--; + + inbuf += 2; + i_len -= 2; + } + + if (o_len == 0 || i_len == 0) + return destlen - o_len; + + /* Keep trying with the next char... */ + goto again; + + } else if (from != CH_UCS2 && to == CH_UCS2) { + /* Can't convert to ucs2 - just widen by adding zero. */ + if (o_len < 2) + return destlen - o_len; + + outbuf[0] = inbuf[0]; + outbuf[1] = '\0'; + + inbuf++; + i_len--; + + outbuf += 2; + o_len -= 2; + + if (o_len == 0 || i_len == 0) + return destlen - o_len; + + /* Keep trying with the next char... */ + goto again; + + } else if (from != CH_UCS2 && to != CH_UCS2) { + /* Failed multibyte to multibyte. Just copy 1 char and + try again. */ + outbuf[0] = inbuf[0]; + + inbuf++; + i_len--; + + outbuf++; + o_len--; + + if (o_len == 0 || i_len == 0) + return destlen - o_len; + + /* Keep trying with the next char... */ + goto again; + + } else { + /* Keep compiler happy.... */ + return destlen - o_len; + } } } @@ -241,9 +310,9 @@ * Fast path version - handles ASCII first. * * @param src pointer to source string (multibyte or singlebyte) - * @param srclen length of the source string in bytes + * @param srclen length of the source string in bytes, or -1 for nul terminated. * @param dest pointer to destination string (multibyte or singlebyte) - * @param destlen maximal length allowed for string + * @param destlen maximal length allowed for string - *NEVER* -1. * @returns the number of bytes occupied in the destination * * Ensure the srclen contains the terminating zero. @@ -257,11 +326,15 @@ void *dest, size_t destlen) { /* - * NB. We deliberately don't do a strlen here is srclen == -1. + * NB. We deliberately don't do a strlen here if srclen == -1. * This is very expensive over millions of calls and is taken * care of in the slow path in convert_string_internal. JRA. */ +#ifdef DEVELOPER + SMB_ASSERT(destlen != (size_t)-1); +#endif + if (srclen == 0) return 0; @@ -302,7 +375,7 @@ unsigned char lastp; /* If all characters are ascii, fast path here. */ - while ((slen >= 2) && dlen) { + while (((slen == (size_t)-1) || (slen >= 2)) && dlen) { if (((lastp = *p) <= 0x7f) && (p[1] == 0)) { *q++ = *p; if (slen != (size_t)-1) { @@ -370,6 +443,9 @@ * @returns Size in bytes of the converted string; or -1 in case of error. * * Ensure the srclen contains the terminating zero. + * + * I hate the goto's in this function. It's embarressing..... + * There has to be a cleaner way to do this. JRA. **/ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to, @@ -398,7 +474,8 @@ goto use_as_is; } -convert: + convert: + if ((destlen*2) < destlen) { /* wrapped ! abort. */ if (!conv_silent) @@ -425,6 +502,9 @@ } i_len = srclen; o_len = destlen; + + again: + retval = smb_iconv(descriptor, (char **)&inbuf, &i_len, &outbuf, &o_len); @@ -449,7 +529,9 @@ /* smb_panic(reason); */ return (size_t)-1; } - + + out: + destlen = destlen - o_len; if (ctx) *dest = (char *)talloc_realloc(ctx,ob,destlen); @@ -464,27 +546,80 @@ return destlen; - use_as_is: + use_as_is: + + /* + * Conversion not supported. This is actually an error, but there are so + * many misconfigured iconv systems and smb.conf's out there we can't just + * fail. Do a very bad conversion instead.... JRA. + */ - /* conversion not supported, use as is */ { - if (srclen && (destlen != srclen)) { - destlen = srclen; - if (ctx) - ob = (char *)talloc_realloc(ctx, ob, destlen); - else - ob = (char *)Realloc(ob, destlen); - if (!ob) { - DEBUG(0, ("convert_string_allocate: realloc failed!\n")); - if (!ctx) - SAFE_FREE(outbuf); - return (size_t)-1; + if (o_len == 0 || i_len == 0) + goto out; + + if (from == CH_UCS2 && to != CH_UCS2) { + /* Can't convert from ucs2 to multibyte. Just truncate this char to ascii. */ + if (i_len < 2) + goto out; + + if (i_len >= 2) { + *outbuf = inbuf[0]; + + outbuf++; + o_len--; + + inbuf += 2; + i_len -= 2; } + + if (o_len == 0 || i_len == 0) + goto out; + + /* Keep trying with the next char... */ + goto again; + + } else if (from != CH_UCS2 && to == CH_UCS2) { + /* Can't convert to ucs2 - just widen by adding zero. */ + if (o_len < 2) + goto out; + + outbuf[0] = inbuf[0]; + outbuf[1] = '\0'; + + inbuf++; + i_len--; + + outbuf += 2; + o_len -= 2; + + if (o_len == 0 || i_len == 0) + goto out; + + /* Keep trying with the next char... */ + goto again; + + } else if (from != CH_UCS2 && to != CH_UCS2) { + /* Failed multibyte to multibyte. Just copy 1 char and + try again. */ + outbuf[0] = inbuf[0]; + + inbuf++; + i_len--; + + outbuf++; + o_len--; + + if (o_len == 0 || i_len == 0) + goto out; + + /* Keep trying with the next char... */ + goto again; + + } else { + /* Keep compiler happy.... */ + goto out; } - if (srclen && ob) - memcpy(ob,(const char *)src,srclen); - *dest = (char *)ob; - return srclen; } } @@ -921,7 +1056,7 @@ if (ucs2_align(base_ptr, src, flags)) { src = (const void *)((const char *)src + 1); - if (src_len > 0) + if (src_len != (size_t)-1) src_len--; } diff -u -r --new-file --exclude=CVS samba-3.0.2rc2/source/lib/util_sock.c samba-3.0.2/source/lib/util_sock.c --- samba-3.0.2rc2/source/lib/util_sock.c Wed Dec 10 15:59:18 2003 +++ samba-3.0.2/source/lib/util_sock.c Fri Feb 6 16:40:30 2004 @@ -552,6 +552,10 @@ smb_read_error = READ_ERROR; return False; } + + /* not all of samba3 properly checks for packet-termination of strings. This + ensures that we don't run off into empty space. */ + SSVAL(buffer+4,len, 0); } return True; diff -u -r --new-file --exclude=CVS samba-3.0.2rc2/source/lib/util_str.c samba-3.0.2/source/lib/util_str.c --- samba-3.0.2rc2/source/lib/util_str.c Sat Jan 31 09:45:57 2004 +++ samba-3.0.2/source/lib/util_str.c Fri Feb 6 16:40:30 2004 @@ -1293,6 +1293,8 @@ void strlower_m(char *s) { + size_t len; + /* this is quite a common operation, so we want it to be fast. We optimise for the ascii case, knowing that all our supported multi-byte character sets are ascii-compatible @@ -1308,7 +1310,12 @@ /* I assume that lowercased string takes the same number of bytes * as source string even in UTF-8 encoding. (VIV) */ - unix_strlower(s,strlen(s)+1,s,strlen(s)+1); + len = strlen(s) + 1; + errno = 0; + unix_strlower(s,len,s,len); + /* Catch mb conversion errors that may not terminate. */ + if (errno) + s[len-1] = '\0'; } /** @@ -1317,6 +1324,8 @@ void strupper_m(char *s) { + size_t len; + /* this is quite a common operation, so we want it to be fast. We optimise for the ascii case, knowing that all our supported multi-byte character sets are ascii-compatible @@ -1332,7 +1341,12 @@ /* I assume that lowercased string takes the same number of bytes * as source string even in multibyte encoding. (VIV) */ - unix_strupper(s,strlen(s)+1,s,strlen(s)+1); + len = strlen(s) + 1; + errno = 0; + unix_strupper(s,len,s,len); + /* Catch mb conversion errors that may not terminate. */ + if (errno) + s[len-1] = '\0'; } /** diff -u -r --new-file --exclude=CVS samba-3.0.2rc2/source/passdb/pdb_interface.c samba-3.0.2/source/passdb/pdb_interface.c --- samba-3.0.2rc2/source/passdb/pdb_interface.c Sat Jan 31 09:45:57 2004 +++ samba-3.0.2/source/passdb/pdb_interface.c Fri Feb 6 16:40:31 2004 @@ -232,12 +232,26 @@ static NTSTATUS context_add_sam_account(struct pdb_context *context, SAM_ACCOUNT *sam_acct) { NTSTATUS ret = NT_STATUS_UNSUCCESSFUL; + const char *lm_pw, *nt_pw; + uint16 acb_flags; if ((!context) || (!context->pdb_methods)) { DEBUG(0, ("invalid pdb_context specified!\n")); return ret; } + /* disable acccounts with no passwords (that has not + been allowed by the ACB_PWNOTREQ bit */ + + lm_pw = pdb_get_lanman_passwd( sam_acct ); + nt_pw = pdb_get_lanman_passwd( sam_acct ); + acb_flags = pdb_get_acct_ctrl( sam_acct ); + if ( !lm_pw && !nt_pw && !(acb_flags&ACB_PWNOTREQ) ) { + acb_flags |= ACB_DISABLED; + pdb_set_acct_ctrl( sam_acct, acb_flags, PDB_SET ); + pdb_set_init_flags(sam_acct, PDB_ACCTCTRL, PDB_SET); + } + /** @todo This is where a 're-read on add' should be done */ /* We now add a new account to the first database listed. * Should we? */ @@ -248,6 +262,8 @@ static NTSTATUS context_update_sam_account(struct pdb_context *context, SAM_ACCOUNT *sam_acct) { NTSTATUS ret = NT_STATUS_UNSUCCESSFUL; + const char *lm_pw, *nt_pw; + uint16 acb_flags; if (!context) { DEBUG(0, ("invalid pdb_context specified!\n")); @@ -259,6 +275,18 @@ return ret; } + /* disable acccounts with no passwords (that has not + been allowed by the ACB_PWNOTREQ bit */ + + lm_pw = pdb_get_lanman_passwd( sam_acct ); + nt_pw = pdb_get_lanman_passwd( sam_acct ); + acb_flags = pdb_get_acct_ctrl( sam_acct ); + if ( !lm_pw && !nt_pw && !(acb_flags&ACB_PWNOTREQ) ) { + acb_flags |= ACB_DISABLED; + pdb_set_acct_ctrl( sam_acct, acb_flags, PDB_SET ); + pdb_set_init_flags(sam_acct, PDB_ACCTCTRL, PDB_SET); + } + /** @todo This is where a 're-read on update' should be done */ return sam_acct->methods->update_sam_account(sam_acct->methods, sam_acct); @@ -708,50 +736,22 @@ BOOL pdb_add_sam_account(SAM_ACCOUNT *sam_acct) { struct pdb_context *pdb_context = pdb_get_static_context(False); - const char *lm_pw, *nt_pw; - uint16 acb_flags; if (!pdb_context) { return False; } - /* disable acccounts with no passwords (that has not - been allowed by the ACB_PWNOTREQ bit */ - - lm_pw = pdb_get_lanman_passwd( sam_acct ); - nt_pw = pdb_get_lanman_passwd( sam_acct ); - acb_flags = pdb_get_acct_ctrl( sam_acct ); - if ( !lm_pw && !nt_pw && !(acb_flags&ACB_PWNOTREQ) ) { - acb_flags |= ACB_DISABLED; - pdb_set_acct_ctrl( sam_acct, acb_flags, PDB_SET ); - pdb_set_init_flags(sam_acct, PDB_ACCTCTRL, PDB_SET); - } - return NT_STATUS_IS_OK(pdb_context->pdb_add_sam_account(pdb_context, sam_acct)); } BOOL pdb_update_sam_account(SAM_ACCOUNT *sam_acct) { struct pdb_context *pdb_context = pdb_get_static_context(False); - const char *lm_pw, *nt_pw; - uint16 acb_flags; if (!pdb_context) { return False; } - /* disable acccounts with no passwords (that has not - been allowed by the ACB_PWNOTREQ bit */ - - lm_pw = pdb_get_lanman_passwd( sam_acct ); - nt_pw = pdb_get_lanman_passwd( sam_acct ); - acb_flags = pdb_get_acct_ctrl( sam_acct ); - if ( !lm_pw && !nt_pw && !(acb_flags&ACB_PWNOTREQ) ) { - acb_flags |= ACB_DISABLED; - pdb_set_acct_ctrl( sam_acct, acb_flags, PDB_SET ); - pdb_set_init_flags(sam_acct, PDB_ACCTCTRL, PDB_SET); - } - return NT_STATUS_IS_OK(pdb_context->pdb_update_sam_account(pdb_context, sam_acct)); }