summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2003-02-10 11:47:21 +0000
committerAndrew Bartlett <abartlet@samba.org>2003-02-10 11:47:21 +0000
commit8a20407442efa0f9fe43e1b1c61140a0771c6ff8 (patch)
treebbf0328ea060ca5986c92f45c7feacecf014be7a
parent4703248a8e7287b738fa82edfd91fb2b13e7c222 (diff)
downloadsamba-8a20407442efa0f9fe43e1b1c61140a0771c6ff8.tar.gz
samba-8a20407442efa0f9fe43e1b1c61140a0771c6ff8.tar.bz2
samba-8a20407442efa0f9fe43e1b1c61140a0771c6ff8.zip
Cleanups: (merge from HEAD)
- use safe_strcpy() instead of pstrcpy() for malloc()ed strings - CUPS: a failure in an attempt to automaticly add a printer is not level 0 stuff. - Fix up a possible Realloc() failure segfault Andrew Bartlett (This used to be commit c1cfc296c2efdb2b5972202146e80f0e3b6a3da4)
-rw-r--r--source3/auth/auth_ntlmssp.c1
-rw-r--r--source3/auth/auth_unix.c2
-rw-r--r--source3/auth/auth_util.c12
-rw-r--r--source3/auth/pass_check.c2
-rw-r--r--source3/locking/locking.c4
-rw-r--r--source3/printing/print_cups.c6
-rw-r--r--source3/smbd/dir.c2
-rw-r--r--source3/smbd/statcache.c4
8 files changed, 21 insertions, 12 deletions
diff --git a/source3/auth/auth_ntlmssp.c b/source3/auth/auth_ntlmssp.c
index 3e650a7a2a..43542b2474 100644
--- a/source3/auth/auth_ntlmssp.c
+++ b/source3/auth/auth_ntlmssp.c
@@ -125,7 +125,6 @@ NTSTATUS auth_ntlmssp_end(AUTH_NTLMSSP_STATE **auth_ntlmssp_state)
if ((*auth_ntlmssp_state)->server_info) {
free_server_info(&(*auth_ntlmssp_state)->server_info);
}
-
talloc_destroy(mem_ctx);
*auth_ntlmssp_state = NULL;
return NT_STATUS_OK;
diff --git a/source3/auth/auth_unix.c b/source3/auth/auth_unix.c
index 1251432b87..4f44767a81 100644
--- a/source3/auth/auth_unix.c
+++ b/source3/auth/auth_unix.c
@@ -106,7 +106,7 @@ static NTSTATUS check_unix_security(const struct auth_context *auth_context,
unbecome_root();
- if NT_STATUS_IS_OK(nt_status) {
+ if (NT_STATUS_IS_OK(nt_status)) {
if (pass) {
make_server_info_pw(server_info, pass);
} else {
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index 5fdfd0694a..bbe0c7cf43 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -671,14 +671,22 @@ static NTSTATUS get_user_groups_from_local_sam(const DOM_SID *user_sid,
};
n_unix_groups = groups_max();
- if ((*unix_groups = malloc( sizeof(gid_t) * groups_max() ) ) == NULL) {
+ if ((*unix_groups = malloc( sizeof(gid_t) * n_unix_groups ) ) == NULL) {
DEBUG(0, ("get_user_groups_from_local_sam: Out of memory allocating unix group list\n"));
passwd_free(&usr);
return NT_STATUS_NO_MEMORY;
}
if (sys_getgrouplist(usr->pw_name, usr->pw_gid, *unix_groups, &n_unix_groups) == -1) {
- *unix_groups = Realloc(*unix_groups, sizeof(gid_t) * n_unix_groups);
+ gid_t *groups_tmp;
+ groups_tmp = Realloc(*unix_groups, sizeof(gid_t) * n_unix_groups);
+ if (!groups_tmp) {
+ SAFE_FREE(*unix_groups);
+ passwd_free(&usr);
+ return NT_STATUS_NO_MEMORY;
+ }
+ *unix_groups = groups_tmp;
+
if (sys_getgrouplist(usr->pw_name, usr->pw_gid, *unix_groups, &n_unix_groups) == -1) {
DEBUG(0, ("get_user_groups_from_local_sam: failed to get the unix group list\n"));
SAFE_FREE(*unix_groups);
diff --git a/source3/auth/pass_check.c b/source3/auth/pass_check.c
index e1783bfd1e..88b82e3474 100644
--- a/source3/auth/pass_check.c
+++ b/source3/auth/pass_check.c
@@ -579,7 +579,7 @@ static NTSTATUS password_check(const char *password)
}
#endif /* HAVE_CRYPT */
#endif /* HAVE_BIGCRYPT && HAVE_CRYPT && USE_BOTH_CRYPT_CALLS */
-#endif /* WITH_PAM || KRB4_AUTH || KRB5_AUTH */
+#endif /* WITH_PAM */
}
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index e5a72d2208..d4794560f6 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -611,6 +611,7 @@ BOOL set_share_mode(files_struct *fsp, uint16 port, uint16 op_type)
/* read in the existing share modes if any */
dbuf = tdb_fetch(tdb, locking_key_fsp(fsp));
if (!dbuf.dptr) {
+ size_t offset;
/* we'll need to create a new record */
pstring fname;
@@ -628,7 +629,8 @@ BOOL set_share_mode(files_struct *fsp, uint16 port, uint16 op_type)
DEBUG(10,("set_share_mode: creating entry for file %s. num_share_modes = 1\n",
fsp->fsp_name ));
- pstrcpy(p + sizeof(*data) + sizeof(share_mode_entry), fname);
+ offset = sizeof(*data) + sizeof(share_mode_entry);
+ safe_strcpy(p + offset, fname, size - offset);
fill_share_mode(p + sizeof(*data), fsp, port, op_type);
dbuf.dptr = p;
dbuf.dsize = size;
diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c
index c283937556..7cf21c966e 100644
--- a/source3/printing/print_cups.c
+++ b/source3/printing/print_cups.c
@@ -332,7 +332,7 @@ int cups_printername_ok(const char *name)
if ((http = httpConnect(cupsServer(), ippPort())) == NULL)
{
- DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
+ DEBUG(3,("Unable to connect to CUPS server %s - %s\n",
cupsServer(), strerror(errno)));
return (0);
}
@@ -374,7 +374,7 @@ int cups_printername_ok(const char *name)
if ((response = cupsDoRequest(http, request, "/")) == NULL)
{
- DEBUG(0,("Unable to get printer status for %s - %s\n", name,
+ DEBUG(3,("Unable to get printer status for %s - %s\n", name,
ippErrorString(cupsLastError())));
httpClose(http);
return (0);
@@ -384,7 +384,7 @@ int cups_printername_ok(const char *name)
if (response->request.status.status_code >= IPP_OK_CONFLICT)
{
- DEBUG(0,("Unable to get printer status for %s - %s\n", name,
+ DEBUG(3,("Unable to get printer status for %s - %s\n", name,
ippErrorString(response->request.status.status_code)));
ippDelete(response);
return (0);
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 9e8de2979b..e022d26ea3 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -907,7 +907,7 @@ void *OpenDir(connection_struct *conn, const char *name, BOOL use_veto)
dirp->current = dirp->data;
}
- pstrcpy(dirp->data+used,n);
+ safe_strcpy(dirp->data+used,n, dirp->mallocsize - used - 1);
used += l;
dirp->numentries++;
}
diff --git a/source3/smbd/statcache.c b/source3/smbd/statcache.c
index 93782b9bb0..f4b613428a 100644
--- a/source3/smbd/statcache.c
+++ b/source3/smbd/statcache.c
@@ -122,8 +122,8 @@ void stat_cache_add( char *full_orig_name, char *orig_translated_path)
DEBUG(0,("stat_cache_add: Out of memory !\n"));
return;
}
- pstrcpy(scp->names, orig_name);
- pstrcpy(scp->names+namelen+1, translated_path);
+ safe_strcpy(scp->names, orig_name, namelen);
+ safe_strcpy(scp->names+namelen+1, translated_path, namelen);
scp->name_len = namelen;
hash_insert(&stat_cache, (char *)scp, orig_name);
}