summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/util/params.c2
-rw-r--r--lib/util/util.h8
-rw-r--r--lib/util/util_file.c59
-rw-r--r--lib/util/util_tdb.c4
-rw-r--r--source3/Makefile.in2
-rw-r--r--source3/include/proto.h14
-rw-r--r--source3/intl/lang_tdb.c6
-rw-r--r--source3/lib/sysquotas.c6
-rw-r--r--source3/lib/util_file.c352
-rw-r--r--source3/libgpo/gpo_ini.c4
-rw-r--r--source3/param/loadparm.c8
-rw-r--r--source3/param/params.c4
-rw-r--r--source3/passdb/machine_sid.c6
-rw-r--r--source3/printing/nt_printing.c8
-rw-r--r--source3/printing/print_generic.c6
-rw-r--r--source3/printing/print_svid.c8
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c18
-rw-r--r--source3/smbd/dfree.c2
-rw-r--r--source3/smbd/lanman.c6
-rw-r--r--source3/smbd/map_username.c4
-rw-r--r--source3/utils/net_usershare.c4
-rw-r--r--source4/auth/credentials/credentials_files.c2
-rw-r--r--source4/lib/registry/dir.c2
-rw-r--r--source4/lib/registry/regf.c2
-rw-r--r--source4/lib/tls/tls.c2
-rw-r--r--source4/torture/gentest.c4
26 files changed, 119 insertions, 424 deletions
diff --git a/lib/util/params.c b/lib/util/params.c
index 3a9e2b9505..c03edec272 100644
--- a/lib/util/params.c
+++ b/lib/util/params.c
@@ -510,7 +510,7 @@ static myFILE *OpenConfFile( const char *FileName )
ret = talloc(talloc_autofree_context(), myFILE);
if (!ret) return NULL;
- ret->buf = file_load(FileName, &ret->size, ret);
+ ret->buf = file_load(FileName, &ret->size, 0, ret);
if( NULL == ret->buf )
{
DEBUG( 1,
diff --git a/lib/util/util.h b/lib/util/util.h
index 5cecad7350..720aa537a7 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -522,12 +522,12 @@ _PUBLIC_ char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint);
/**
load a file into memory from a fd.
**/
-_PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx);
+_PUBLIC_ char *fd_load(int fd, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx);
/**
load a file into memory
**/
-_PUBLIC_ char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx);
+_PUBLIC_ char *file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx);
/**
mmap (if possible) or read a file
@@ -538,14 +538,14 @@ _PUBLIC_ void *map_file(const char *fname, size_t size);
load a file into memory and return an array of pointers to lines in the file
must be freed with talloc_free().
**/
-_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, TALLOC_CTX *mem_ctx);
+_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx);
/**
load a fd into memory and return an array of pointers to lines in the file
must be freed with talloc_free(). If convert is true calls unix_to_dos on
the list.
**/
-_PUBLIC_ char **fd_lines_load(int fd, int *numlines, TALLOC_CTX *mem_ctx);
+_PUBLIC_ char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx);
/**
take a list of lines and modify them to produce a list where \ continues
diff --git a/lib/util/util_file.c b/lib/util/util_file.c
index c3e22196c0..176ff75e02 100644
--- a/lib/util/util_file.c
+++ b/lib/util/util_file.c
@@ -22,6 +22,11 @@
#include "includes.h"
#include "system/shmem.h"
#include "system/filesys.h"
+#if _SAMBA_BUILD_ == 3
+#undef malloc
+#undef realloc
+#define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count, false)
+#endif
/**
* @file
@@ -160,23 +165,30 @@ _PUBLIC_ char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint)
/**
load a file into memory from a fd.
**/
-_PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx)
+_PUBLIC_ char *fd_load(int fd, size_t *psize, size_t maxsize, TALLOC_CTX *mem_ctx)
{
struct stat sbuf;
char *p;
+ size_t size;
if (fstat(fd, &sbuf) != 0) return NULL;
- p = (char *)talloc_size(mem_ctx, sbuf.st_size+1);
+ size = sbuf.st_size;
+
+ if (maxsize) {
+ size = MIN(size, maxsize);
+ }
+
+ p = (char *)talloc_size(mem_ctx, size+1);
if (!p) return NULL;
- if (read(fd, p, sbuf.st_size) != sbuf.st_size) {
+ if (read(fd, p, size) != size) {
talloc_free(p);
return NULL;
}
- p[sbuf.st_size] = 0;
+ p[size] = 0;
- if (size) *size = sbuf.st_size;
+ if (psize) *psize = size;
return p;
}
@@ -184,7 +196,7 @@ _PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx)
/**
load a file into memory
**/
-_PUBLIC_ char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx)
+_PUBLIC_ char *file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx)
{
int fd;
char *p;
@@ -194,7 +206,7 @@ _PUBLIC_ char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx)
fd = open(fname,O_RDONLY);
if (fd == -1) return NULL;
- p = fd_load(fd, size, mem_ctx);
+ p = fd_load(fd, size, maxsize, mem_ctx);
close(fd);
@@ -224,7 +236,7 @@ _PUBLIC_ void *map_file(const char *fname, size_t size)
}
#endif
if (!p) {
- p = file_load(fname, &s2, talloc_autofree_context());
+ p = file_load(fname, &s2, 0, talloc_autofree_context());
if (!p) return NULL;
if (s2 != size) {
DEBUG(1,("incorrect size for %s - got %d expected %d\n",
@@ -237,12 +249,31 @@ _PUBLIC_ void *map_file(const char *fname, size_t size)
return p;
}
+/**
+ unmap or free memory
+**/
+
+bool unmap_file(void *start, size_t size)
+{
+#ifdef HAVE_MMAP
+ if (munmap( start, size ) != 0) {
+ DEBUG( 1, ("map_file: Failed to unmap address %p "
+ "of size %u - %s\n",
+ start, (unsigned int)size, strerror(errno) ));
+ return false;
+ }
+ return true;
+#else
+ talloc_free(start);
+ return true;
+#endif
+}
/**
parse a buffer into lines
'p' will be freed on error, and otherwise will be made a child of the returned array
**/
-static char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx)
+char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx)
{
int i;
char *s, **ret;
@@ -288,12 +319,12 @@ static char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *
load a file into memory and return an array of pointers to lines in the file
must be freed with talloc_free().
**/
-_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, TALLOC_CTX *mem_ctx)
+_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx)
{
char *p;
size_t size;
- p = file_load(fname, &size, mem_ctx);
+ p = file_load(fname, &size, maxsize, mem_ctx);
if (!p) return NULL;
return file_lines_parse(p, size, numlines, mem_ctx);
@@ -304,12 +335,12 @@ load a fd into memory and return an array of pointers to lines in the file
must be freed with talloc_free(). If convert is true calls unix_to_dos on
the list.
**/
-_PUBLIC_ char **fd_lines_load(int fd, int *numlines, TALLOC_CTX *mem_ctx)
+_PUBLIC_ char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx)
{
char *p;
size_t size;
- p = fd_load(fd, &size, mem_ctx);
+ p = fd_load(fd, &size, maxsize, mem_ctx);
if (!p) return NULL;
return file_lines_parse(p, size, numlines, mem_ctx);
@@ -402,3 +433,5 @@ _PUBLIC_ bool large_file_support(const char *path)
close(fd);
return ret == 0;
}
+
+
diff --git a/lib/util/util_tdb.c b/lib/util/util_tdb.c
index 299f5f7c6a..2d6012c9f4 100644
--- a/lib/util/util_tdb.c
+++ b/lib/util/util_tdb.c
@@ -40,12 +40,12 @@ TDB_DATA make_tdb_data(const uint8_t *dptr, size_t dsize)
TDB_DATA string_tdb_data(const char *string)
{
- return make_tdb_data((const uint8 *)string, string ? strlen(string) : 0 );
+ return make_tdb_data((const uint8_t *)string, string ? strlen(string) : 0 );
}
TDB_DATA string_term_tdb_data(const char *string)
{
- return make_tdb_data((const uint8 *)string, string ? strlen(string) + 1 : 0);
+ return make_tdb_data((const uint8_t *)string, string ? strlen(string) + 1 : 0);
}
/****************************************************************************
diff --git a/source3/Makefile.in b/source3/Makefile.in
index a72d673b1b..3297278d87 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -326,7 +326,7 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) \
lib/bitmap.o ../lib/crypto/crc32.o lib/dprintf.o $(UTIL_REG_OBJ) \
../lib/util/xfile.o ../lib/util/util_strlist.o lib/wins_srv.o \
lib/util_str.o lib/clobber.o lib/util_sid.o lib/util_uuid.o \
- lib/util_unistr.o lib/util_file.o ../lib/util/data_blob.o \
+ lib/util_unistr.o ../lib/util/util_file.o lib/util_file.o ../lib/util/data_blob.o \
lib/util.o lib/util_sock.o lib/sock_exec.o lib/util_sec.o \
lib/substitute.o lib/fsusage.o lib/dbwrap_util.o \
lib/ms_fnmatch.o lib/select.o lib/errmap_unix.o \
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 08c1e2c810..0a5c401952 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1362,16 +1362,16 @@ const char *strip_hostname(const char *s);
/* The following definitions come from lib/util_file.c */
char *fgets_slash(char *s2,int maxlen,XFILE *f);
-char *fd_load(int fd, size_t *psize, size_t maxsize);
-char *file_load(const char *fname, size_t *size, size_t maxsize);
+char *file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx);
+char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx);
bool unmap_file(void* start, size_t size);
-void *map_file(char *fname, size_t size);
-char **file_lines_load(const char *fname, int *numlines, size_t maxsize);
-char **fd_lines_load(int fd, int *numlines, size_t maxsize);
-char **file_lines_pload(char *syscmd, int *numlines);
+void *map_file(const char *fname, size_t size);
+char **file_lines_load(const char *fname, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx);
+char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx);
+char **file_lines_pload(const char *syscmd, int *numlines);
void file_lines_free(char **lines);
void file_lines_slashcont(char **lines);
-bool file_save(const char *fname, void *packet, size_t length);
+bool file_save(const char *fname, const void *packet, size_t length);
/* The following definitions come from lib/util_nscd.c */
diff --git a/source3/intl/lang_tdb.c b/source3/intl/lang_tdb.c
index 499b9eb87d..ac7e9dda40 100644
--- a/source3/intl/lang_tdb.c
+++ b/source3/intl/lang_tdb.c
@@ -33,14 +33,14 @@ static bool load_msg(const char *msg_file)
char *msgid, *msgstr;
TDB_DATA data;
- lines = file_lines_load(msg_file, &num_lines,0);
+ lines = file_lines_load(msg_file, &num_lines, 0, NULL);
if (!lines) {
return False;
}
if (tdb_lockall(tdb) != 0) {
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return False;
}
@@ -68,7 +68,7 @@ static bool load_msg(const char *msg_file)
}
}
- file_lines_free(lines);
+ TALLOC_FREE(lines);
tdb_unlockall(tdb);
return True;
diff --git a/source3/lib/sysquotas.c b/source3/lib/sysquotas.c
index 4a2d88abdf..5ee199de22 100644
--- a/source3/lib/sysquotas.c
+++ b/source3/lib/sysquotas.c
@@ -295,7 +295,7 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
dp->bsize = 1024;
}
- file_lines_free(lines);
+ TALLOC_FREE(lines);
lines = NULL;
DEBUG (3, ("Parsed output of get_quota, ...\n"));
@@ -331,7 +331,7 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
invalid_param:
- file_lines_free(lines);
+ TALLOC_FREE(lines);
DEBUG(0,("The output of get_quota_command is invalid!\n"));
return -1;
}
@@ -392,7 +392,7 @@ static int command_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
DEBUG (3, ("Read output from set_quota, \"%s\"\n", line));
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return 0;
}
diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c
index b628b06cc6..c5a9b7c29a 100644
--- a/source3/lib/util_file.c
+++ b/source3/lib/util_file.c
@@ -19,89 +19,11 @@
#include "includes.h"
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *)-1)
-#endif
-
-/****************************************************************************
- Read a line from a file with possible \ continuation chars.
- Blanks at the start or end of a line are stripped.
- The string will be allocated if s2 is NULL.
-****************************************************************************/
-
-char *fgets_slash(char *s2,int maxlen,XFILE *f)
-{
- char *s=s2;
- int len = 0;
- int c;
- bool start_of_line = True;
-
- if (x_feof(f)) {
- return(NULL);
- }
-
- if (maxlen <2) {
- return(NULL);
- }
-
- if (!s2) {
- maxlen = MIN(maxlen,8);
- s = (char *)SMB_MALLOC(maxlen);
- }
-
- if (!s) {
- return(NULL);
- }
-
- *s = 0;
-
- while (len < maxlen-1) {
- c = x_getc(f);
- switch (c) {
- case '\r':
- break;
- case '\n':
- while (len > 0 && s[len-1] == ' ') {
- s[--len] = 0;
- }
- if (len > 0 && s[len-1] == '\\') {
- s[--len] = 0;
- start_of_line = True;
- break;
- }
- return(s);
- case EOF:
- if (len <= 0 && !s2) {
- SAFE_FREE(s);
- }
- return(len>0?s:NULL);
- case ' ':
- if (start_of_line) {
- break;
- }
- default:
- start_of_line = False;
- s[len++] = c;
- s[len] = 0;
- }
-
- if (!s2 && len > maxlen-3) {
- maxlen *= 2;
- s = (char *)SMB_REALLOC(s,maxlen);
- if (!s) {
- DEBUG(0,("fgets_slash: failed to expand buffer!\n"));
- return(NULL);
- }
- }
- }
- return(s);
-}
-
-/****************************************************************************
+/**
Load from a pipe into memory.
-****************************************************************************/
+**/
-static char *file_pload(char *syscmd, size_t *size)
+static char *file_pload(const char *syscmd, size_t *size)
{
int fd, n;
char *p;
@@ -143,215 +65,14 @@ static char *file_pload(char *syscmd, size_t *size)
return p;
}
-/****************************************************************************
- Load a file into memory from a fd.
- Truncate at maxsize. If maxsize == 0 - no limit.
-****************************************************************************/
-
-char *fd_load(int fd, size_t *psize, size_t maxsize)
-{
- SMB_STRUCT_STAT sbuf;
- size_t size;
- char *p;
-
- if (sys_fstat(fd, &sbuf) != 0) {
- return NULL;
- }
-
- size = sbuf.st_size;
- if (maxsize) {
- size = MIN(size, maxsize);
- }
-
- p = (char *)SMB_MALLOC(size+1);
- if (!p) {
- return NULL;
- }
-
- if (read(fd, p, size) != size) {
- SAFE_FREE(p);
- return NULL;
- }
- p[size] = 0;
-
- if (psize) {
- *psize = size;
- }
-
- return p;
-}
-
-/****************************************************************************
- Load a file into memory.
-****************************************************************************/
-
-char *file_load(const char *fname, size_t *size, size_t maxsize)
-{
- int fd;
- char *p;
-
- if (!fname || !*fname) {
- return NULL;
- }
-
- fd = open(fname,O_RDONLY);
- if (fd == -1) {
- return NULL;
- }
-
- p = fd_load(fd, size, maxsize);
- close(fd);
- return p;
-}
-
-/*******************************************************************
- unmap or free memory
-*******************************************************************/
-
-bool unmap_file(void* start, size_t size)
-{
-#ifdef HAVE_MMAP
- if ( munmap( start, size ) != 0 ) {
- DEBUG( 1, ("map_file: Failed to unmap address %p "
- "of size %u - %s\n",
- start, (unsigned int)size, strerror(errno) ));
- return False;
- }
- return True;
-#else
- SAFE_FREE( start );
- return True;
-#endif
-}
-
-/*******************************************************************
- mmap (if possible) or read a file.
-********************************************************************/
-
-void *map_file(char *fname, size_t size)
-{
- size_t s2 = 0;
- void *p = NULL;
-#ifdef HAVE_MMAP
- int fd;
- fd = open(fname, O_RDONLY, 0);
- if (fd == -1) {
- DEBUG(2,("map_file: Failed to load %s - %s\n", fname, strerror(errno)));
- return NULL;
- }
- p = mmap(NULL, size, PROT_READ, MAP_SHARED|MAP_FILE, fd, 0);
- close(fd);
- if (p == MAP_FAILED) {
- DEBUG(1,("map_file: Failed to mmap %s - %s\n", fname, strerror(errno)));
- return NULL;
- }
-#endif
- if (!p) {
- p = file_load(fname, &s2, 0);
- if (!p) {
- return NULL;
- }
- if (s2 != size) {
- DEBUG(1,("map_file: incorrect size for %s - got %lu expected %lu\n",
- fname, (unsigned long)s2, (unsigned long)size));
- SAFE_FREE(p);
- return NULL;
- }
- }
- return p;
-}
-
-/****************************************************************************
- Parse a buffer into lines.
-****************************************************************************/
-
-static char **file_lines_parse(char *p, size_t size, int *numlines)
-{
- int i;
- char *s, **ret;
-
- if (!p) {
- return NULL;
- }
-
- for (s = p, i=0; s < p+size; s++) {
- if (s[0] == '\n') i++;
- }
-
- ret = SMB_MALLOC_ARRAY(char *, i+2);
- if (!ret) {
- SAFE_FREE(p);
- return NULL;
- }
- memset(ret, 0, sizeof(ret[0])*(i+2));
-
- ret[0] = p;
- for (s = p, i=0; s < p+size; s++) {
- if (s[0] == '\n') {
- s[0] = 0;
- i++;
- ret[i] = s+1;
- }
- if (s[0] == '\r') {
- s[0] = 0;
- }
- }
-
- /* remove any blank lines at the end */
- while (i > 0 && ret[i-1][0] == 0) {
- i--;
- }
-
- if (numlines) {
- *numlines = i;
- }
-
- return ret;
-}
-
-/****************************************************************************
- Load a file into memory and return an array of pointers to lines in the file
- must be freed with file_lines_free().
-****************************************************************************/
-
-char **file_lines_load(const char *fname, int *numlines, size_t maxsize)
-{
- char *p;
- size_t size = 0;
-
- p = file_load(fname, &size, maxsize);
- if (!p) {
- return NULL;
- }
-
- return file_lines_parse(p, size, numlines);
-}
-
-/****************************************************************************
- Load a fd into memory and return an array of pointers to lines in the file
- must be freed with file_lines_free(). If convert is true calls unix_to_dos on
- the list.
-****************************************************************************/
-char **fd_lines_load(int fd, int *numlines, size_t maxsize)
-{
- char *p;
- size_t size;
- p = fd_load(fd, &size, maxsize);
- if (!p) {
- return NULL;
- }
-
- return file_lines_parse(p, size, numlines);
-}
-
-/****************************************************************************
+/**
Load a pipe into memory and return an array of pointers to lines in the data
must be freed with file_lines_free().
-****************************************************************************/
+**/
-char **file_lines_pload(char *syscmd, int *numlines)
+char **file_lines_pload(const char *syscmd, int *numlines)
{
char *p;
size_t size;
@@ -361,64 +82,5 @@ char **file_lines_pload(char *syscmd, int *numlines)
return NULL;
}
- return file_lines_parse(p, size, numlines);
-}
-
-/****************************************************************************
- Free lines loaded with file_lines_load.
-****************************************************************************/
-
-void file_lines_free(char **lines)
-{
- if (!lines) {
- return;
- }
- SAFE_FREE(lines[0]);
- SAFE_FREE(lines);
-}
-
-/****************************************************************************
- Take a list of lines and modify them to produce a list where \ continues
- a line.
-****************************************************************************/
-
-void file_lines_slashcont(char **lines)
-{
- int i, j;
-
- for (i=0; lines[i];) {
- int len = strlen(lines[i]);
- if (lines[i][len-1] == '\\') {
- lines[i][len-1] = ' ';
- if (lines[i+1]) {
- char *p = &lines[i][len];
- while (p < lines[i+1]) {
- *p++ = ' ';
- }
- for (j = i+1; lines[j]; j++) {
- lines[j] = lines[j+1];
- }
- }
- } else {
- i++;
- }
- }
-}
-
-/****************************************************************************
- Save a lump of data into a file. Mostly used for debugging.
-****************************************************************************/
-
-bool file_save(const char *fname, void *packet, size_t length)
-{
- int fd;
- fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0644);
- if (fd == -1) {
- return False;
- }
- if (write(fd, packet, length) != (size_t)length) {
- return False;
- }
- close(fd);
- return True;
+ return file_lines_parse(p, size, numlines, NULL);
}
diff --git a/source3/libgpo/gpo_ini.c b/source3/libgpo/gpo_ini.c
index 54aaffa477..aa8f7c7770 100644
--- a/source3/libgpo/gpo_ini.c
+++ b/source3/libgpo/gpo_ini.c
@@ -63,7 +63,7 @@ static NTSTATUS convert_file_from_ucs2(TALLOC_CTX *mem_ctx,
return NT_STATUS_INVALID_PARAMETER;
}
- data_in = (uint8 *)file_load(filename_in, &n, 0);
+ data_in = (uint8 *)file_load(filename_in, &n, 0, NULL);
if (!data_in) {
status = NT_STATUS_NO_SUCH_FILE;
goto out;
@@ -116,7 +116,7 @@ static NTSTATUS convert_file_from_ucs2(TALLOC_CTX *mem_ctx,
close(tmp_fd);
}
- SAFE_FREE(data_in);
+ TALLOC_FREE(data_in);
return status;
}
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 58efa57bab..d646a79334 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -8385,7 +8385,7 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i
return -1;
}
- lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE);
+ lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
close(fd);
if (lines == NULL) {
@@ -8400,7 +8400,7 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i
/* Should we allow printers to be shared... ? */
ctx = talloc_init("usershare_sd_xctx");
if (!ctx) {
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return 1;
}
@@ -8408,11 +8408,11 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i
iService, lines, numlines, &sharepath,
&comment, &psd, &guest_ok) != USERSHARE_OK) {
talloc_destroy(ctx);
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return -1;
}
- file_lines_free(lines);
+ TALLOC_FREE(lines);
/* Everything ok - add the service possibly using a template. */
if (iService < 0) {
diff --git a/source3/param/params.c b/source3/param/params.c
index 478376c9e9..97db613fc4 100644
--- a/source3/param/params.c
+++ b/source3/param/params.c
@@ -118,7 +118,7 @@ static void myfile_close(myFILE *f)
{
if (!f)
return;
- SAFE_FREE(f->buf);
+ TALLOC_FREE(f->buf);
SAFE_FREE(f);
}
@@ -525,7 +525,7 @@ static myFILE *OpenConfFile( const char *FileName )
if (!ret)
return NULL;
- ret->buf = file_load(FileName, &ret->size, 0);
+ ret->buf = file_load(FileName, &ret->size, 0, NULL);
if( NULL == ret->buf ) {
DEBUG( lvl, ("%s Unable to open configuration file \"%s\":\n\t%s\n",
func, FileName, strerror(errno)) );
diff --git a/source3/passdb/machine_sid.c b/source3/passdb/machine_sid.c
index ff2c9bcb0d..c7c3cc474b 100644
--- a/source3/passdb/machine_sid.c
+++ b/source3/passdb/machine_sid.c
@@ -41,15 +41,15 @@ static bool read_sid_from_file(const char *fname, DOM_SID *sid)
int numlines;
bool ret;
- lines = file_lines_load(fname, &numlines,0);
+ lines = file_lines_load(fname, &numlines,0, NULL);
if (!lines || numlines < 1) {
- if (lines) file_lines_free(lines);
+ if (lines) TALLOC_FREE(lines);
return False;
}
ret = string_to_sid(sid, lines[0]);
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return ret;
}
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 850375e82b..13a6403b1c 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -3925,10 +3925,10 @@ static void map_to_os2_driver(fstring drivername)
return;
}
- lines = file_lines_load(mapfile, &numlines,0);
+ lines = file_lines_load(mapfile, &numlines,0,NULL);
if (numlines == 0 || lines == NULL) {
DEBUG(0,("No entries in OS/2 driver map %s\n",mapfile));
- SAFE_FREE(lines);
+ TALLOC_FREE(lines);
return;
}
@@ -3972,12 +3972,12 @@ static void map_to_os2_driver(fstring drivername)
DEBUG(3,("Mapped windows driver %s to os2 driver%s\n",drivername,os2_name));
set_last_from_to(drivername,os2_name);
fstrcpy(drivername,os2_name);
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return;
}
}
- file_lines_free(lines);
+ TALLOC_FREE(lines);
}
/****************************************************************************
diff --git a/source3/printing/print_generic.c b/source3/printing/print_generic.c
index 0c05915bd8..5806b29206 100644
--- a/source3/printing/print_generic.c
+++ b/source3/printing/print_generic.c
@@ -238,7 +238,7 @@ static int generic_queue_get(const char *printer_name,
}
numlines = 0;
- qlines = fd_lines_load(fd, &numlines,0);
+ qlines = fd_lines_load(fd, &numlines,0,NULL);
close(fd);
/* turn the lpq output into a series of job structures */
@@ -247,7 +247,7 @@ static int generic_queue_get(const char *printer_name,
if (numlines && qlines) {
queue = SMB_MALLOC_ARRAY(print_queue_struct, numlines+1);
if (!queue) {
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
*q = NULL;
return 0;
}
@@ -262,7 +262,7 @@ static int generic_queue_get(const char *printer_name,
}
}
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
*q = queue;
return qcount;
}
diff --git a/source3/printing/print_svid.c b/source3/printing/print_svid.c
index 7e91d3a677..681b2bf459 100644
--- a/source3/printing/print_svid.c
+++ b/source3/printing/print_svid.c
@@ -59,12 +59,12 @@ bool sysv_cache_reload(void)
scheduler = file_lines_pload("/usr/bin/lpstat -r", NULL);
if(!strcmp(*scheduler,"scheduler is running")){
DEBUG(3,("No Printers found!!!\n"));
- file_lines_free(scheduler);
+ TALLOC_FREE(scheduler);
return True;
}
else{
DEBUG(3,("Scheduler is not running!!!\n"));
- file_lines_free(scheduler);
+ TALLOC_FREE(scheduler);
return False;
}
#else
@@ -111,12 +111,12 @@ bool sysv_cache_reload(void)
/* add it to the cache */
if (!pcap_cache_add(name, NULL)) {
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return False;
}
}
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return True;
}
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 635898a9d5..52cb02b109 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -6280,7 +6280,7 @@ bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEV
numlines = 0;
/* Get lines and convert them back to dos-codepage */
- qlines = fd_lines_load(fd, &numlines, 0);
+ qlines = fd_lines_load(fd, &numlines, 0, NULL);
DEBUGADD(10,("Lines returned = [%d]\n", numlines));
close(fd);
@@ -6293,7 +6293,7 @@ bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEV
DEBUGADD(6,("Line[0] = [%s]\n", qlines[0]));
}
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
return True;
}
@@ -7512,7 +7512,7 @@ WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines )
}
numlines = 0;
- qlines = fd_lines_load(fd, &numlines, 0);
+ qlines = fd_lines_load(fd, &numlines, 0, NULL);
DEBUGADD(10,("Lines returned = [%d]\n", numlines));
close(fd);
}
@@ -7537,7 +7537,7 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need
result = enumports_hook(talloc_tos(), &numlines, &qlines );
if (!W_ERROR_IS_OK(result)) {
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
return result;
}
@@ -7545,7 +7545,7 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need
if((ports=SMB_MALLOC_ARRAY( PORT_INFO_1, numlines )) == NULL) {
DEBUG(10,("Returning WERR_NOMEM [%s]\n",
dos_errstr(WERR_NOMEM)));
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
return WERR_NOMEM;
}
@@ -7554,7 +7554,7 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need
fill_port_1(&ports[i], qlines[i]);
}
}
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
*returned = numlines;
@@ -7603,13 +7603,13 @@ static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *need
result = enumports_hook(talloc_tos(), &numlines, &qlines );
if ( !W_ERROR_IS_OK(result)) {
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
return result;
}
if(numlines) {
if((ports=SMB_MALLOC_ARRAY( PORT_INFO_2, numlines)) == NULL) {
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
return WERR_NOMEM;
}
@@ -7619,7 +7619,7 @@ static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *need
}
}
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
*returned = numlines;
diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c
index 1ddcd48d40..282027ee5a 100644
--- a/source3/smbd/dfree.c
+++ b/source3/smbd/dfree.c
@@ -112,7 +112,7 @@ SMB_BIG_UINT sys_disk_free(connection_struct *conn, const char *path, bool small
*bsize = STR_TO_SMB_BIG_UINT(p, NULL);
else
*bsize = 1024;
- file_lines_free(lines);
+ TALLOC_FREE(lines);
DEBUG (3, ("Parsed output of dfree, dsize=%u, dfree=%u, bsize=%u\n",
(unsigned int)*dsize, (unsigned int)*dfree, (unsigned int)*bsize));
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index fe1d766b9d..0c866da706 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -1154,7 +1154,7 @@ static int get_server_info(uint32 servertype,
bool local_list_only;
int i;
- lines = file_lines_load(lock_path(SERVER_LIST), NULL, 0);
+ lines = file_lines_load(lock_path(SERVER_LIST), NULL, 0, NULL);
if (!lines) {
DEBUG(4,("Can't open %s - %s\n",lock_path(SERVER_LIST),strerror(errno)));
return 0;
@@ -1186,7 +1186,7 @@ static int get_server_info(uint32 servertype,
*servers = SMB_REALLOC_ARRAY(*servers,struct srv_info_struct, alloced);
if (!*servers) {
DEBUG(0,("get_server_info: failed to enlarge servers info struct!\n"));
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return 0;
}
memset((char *)((*servers)+count),'\0',sizeof(**servers)*(alloced-count));
@@ -1267,7 +1267,7 @@ static int get_server_info(uint32 servertype,
}
}
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return count;
}
diff --git a/source3/smbd/map_username.c b/source3/smbd/map_username.c
index 7536758bcb..a8899dd538 100644
--- a/source3/smbd/map_username.c
+++ b/source3/smbd/map_username.c
@@ -116,7 +116,7 @@ bool map_username(fstring user)
}
numlines = 0;
- qlines = fd_lines_load(fd, &numlines,0);
+ qlines = fd_lines_load(fd, &numlines,0, NULL);
DEBUGADD(10,("Lines returned = [%d]\n", numlines));
close(fd);
@@ -127,7 +127,7 @@ bool map_username(fstring user)
fstrcpy( user, qlines[0] );
}
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
return numlines != 0;
}
diff --git a/source3/utils/net_usershare.c b/source3/utils/net_usershare.c
index 8f263c636c..ce8e82182e 100644
--- a/source3/utils/net_usershare.c
+++ b/source3/utils/net_usershare.c
@@ -371,7 +371,7 @@ static int info_fn(struct file_list *fl, void *priv)
return -1;
}
- lines = fd_lines_load(fd, &numlines, 10240);
+ lines = fd_lines_load(fd, &numlines, 10240, NULL);
close(fd);
if (lines == NULL) {
@@ -385,7 +385,7 @@ static int info_fn(struct file_list *fl, void *priv)
&psd,
&guest_ok);
- file_lines_free(lines);
+ TALLOC_FREE(lines);
if (us_err != USERSHARE_OK) {
d_fprintf(stderr, "info_fn: file %s is not a well formed usershare file.\n",
diff --git a/source4/auth/credentials/credentials_files.c b/source4/auth/credentials/credentials_files.c
index 364e80a3a6..8f4f8c9561 100644
--- a/source4/auth/credentials/credentials_files.c
+++ b/source4/auth/credentials/credentials_files.c
@@ -118,7 +118,7 @@ _PUBLIC_ bool cli_credentials_parse_file(struct cli_credentials *cred, const cha
char **lines;
int i, numlines;
- lines = file_lines_load(file, &numlines, NULL);
+ lines = file_lines_load(file, &numlines, 0, NULL);
if (lines == NULL)
{
diff --git a/source4/lib/registry/dir.c b/source4/lib/registry/dir.c
index 449ee0f6ee..42946bceec 100644
--- a/source4/lib/registry/dir.c
+++ b/source4/lib/registry/dir.c
@@ -327,7 +327,7 @@ static WERROR reg_dir_get_value(TALLOC_CTX *mem_ctx,
size_t size;
char *contents;
- contents = file_load(path, &size, mem_ctx);
+ contents = file_load(path, &size, 0, mem_ctx);
talloc_free(path);
if (contents == NULL)
return WERR_BADFILE;
diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c
index 57a895aa00..dd3ff47b78 100644
--- a/source4/lib/registry/regf.c
+++ b/source4/lib/registry/regf.c
@@ -2066,7 +2066,7 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx, const char *location,
pull = tdr_pull_init(regf, regf->iconv_convenience);
- pull->data.data = (uint8_t*)fd_load(regf->fd, &pull->data.length, regf);
+ pull->data.data = (uint8_t*)fd_load(regf->fd, &pull->data.length, 0, regf);
if (pull->data.data == NULL) {
DEBUG(0, ("Error reading data\n"));
diff --git a/source4/lib/tls/tls.c b/source4/lib/tls/tls.c
index b298fb10cf..046c2b9036 100644
--- a/source4/lib/tls/tls.c
+++ b/source4/lib/tls/tls.c
@@ -421,7 +421,7 @@ struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx, struct loadparm_context *
if (dhpfile && *dhpfile) {
gnutls_datum_t dhparms;
size_t size;
- dhparms.data = (uint8_t *)file_load(dhpfile, &size, mem_ctx);
+ dhparms.data = (uint8_t *)file_load(dhpfile, &size, 0, mem_ctx);
if (!dhparms.data) {
DEBUG(0,("Failed to read DH Parms from %s\n", dhpfile));
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
index 3bf3ad8b1b..74ece99422 100644
--- a/source4/torture/gentest.c
+++ b/source4/torture/gentest.c
@@ -3046,7 +3046,7 @@ static bool start_gentest(struct event_context *ev,
/* generate the seeds - after this everything is deterministic */
if (options.use_preset_seeds) {
int numops;
- char **preset = file_lines_load(options.seeds_file, &numops, NULL);
+ char **preset = file_lines_load(options.seeds_file, &numops, 0, NULL);
if (!preset) {
printf("Failed to load %s - %s\n", options.seeds_file, strerror(errno));
exit(1);
@@ -3193,7 +3193,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
}
if (ignore_file) {
- options.ignore_patterns = file_lines_load(ignore_file, NULL, NULL);
+ options.ignore_patterns = file_lines_load(ignore_file, NULL, 0, NULL);
}
argv_new = discard_const_p(char *, poptGetArgs(pc));