summaryrefslogtreecommitdiffstats
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-06-23 17:31:38 +0000
committerJeremy Allison <jra@samba.org>2000-06-23 17:31:38 +0000
commit5dd2bd50768ef57072e27b42faf7790875c7bae8 (patch)
tree60aa05e1403f98cbc6684f4b4b7afad67cc40969 /source3
parent8a62ee49746a32d1c0b8c3f3261b3a38c667d00b (diff)
downloadsamba-5dd2bd50768ef57072e27b42faf7790875c7bae8.tar.gz
samba-5dd2bd50768ef57072e27b42faf7790875c7bae8.tar.xz
samba-5dd2bd50768ef57072e27b42faf7790875c7bae8.zip
lib/util_unistr.c: Off-by-one fix for dos_PutUniStr from John Reilly jreilly@hp.com.
Memory leak fix for new sec_ctx code (sorry Tim :-). Jeremy. (This used to be commit edaf49c66d5a5ccf6689b358c301e208599a468f)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/util_unistr.c2
-rw-r--r--source3/smbd/sec_ctx.c6
2 files changed, 6 insertions, 2 deletions
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c
index d4a159a28e7..1c13ff2758e 100644
--- a/source3/lib/util_unistr.c
+++ b/source3/lib/util_unistr.c
@@ -55,7 +55,7 @@ static uint16 *ucs2_to_unixcp;
size_t dos_PutUniCode(char *dst,const char *src, ssize_t len, BOOL null_terminate)
{
size_t ret = 0;
- while (*src && (len > 2)) {
+ while (*src && (len >= 2)) {
size_t skip = get_character_len(*src);
smb_ucs2_t val = (*src & 0xff);
diff --git a/source3/smbd/sec_ctx.c b/source3/smbd/sec_ctx.c
index e3aac77d8e4..bbd801d76b3 100644
--- a/source3/smbd/sec_ctx.c
+++ b/source3/smbd/sec_ctx.c
@@ -184,11 +184,15 @@ void set_sec_ctx(uid_t uid, gid_t gid, int ngroups, gid_t *groups)
#ifdef HAVE_SETGROUPS
sys_setgroups(ngroups, groups);
+#endif
sec_ctx_stack[sec_ctx_stack_ndx].ngroups = ngroups;
+
+ if (sec_ctx_stack[sec_ctx_stack_ndx].groups != NULL)
+ free(sec_ctx_stack[sec_ctx_stack_ndx].groups);
+
sec_ctx_stack[sec_ctx_stack_ndx].groups =
memdup(groups, sizeof(gid_t) * ngroups);
-#endif
become_id(uid, gid);