summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorTim Prouty <tim.prouty@isilon.com>2008-04-29 14:36:24 -0700
committerVolker Lendecke <vl@samba.org>2008-05-20 22:40:13 +0200
commitfb37f156009611af0dd454a0fb0829a09cd638ac (patch)
treee97403a13dd39b7ef485d36c6c7856045e6e4bf3 /source3/smbd
parent6ed27edbcd3ba1893636a8072c8d7a621437daf7 (diff)
downloadsamba-fb37f156009611af0dd454a0fb0829a09cd638ac.tar.gz
samba-fb37f156009611af0dd454a0fb0829a09cd638ac.tar.bz2
samba-fb37f156009611af0dd454a0fb0829a09cd638ac.zip
Cleanup size_t return values in callers of convert_string_allocate
This patch is the second iteration of an inside-out conversion to cleanup functions in charcnv.c returning size_t == -1 to indicate failure. (This used to be commit 6b189dabc562d86dcaa685419d0cb6ea276f100d)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/lanman.c9
-rw-r--r--source3/smbd/mangle_hash.c11
-rw-r--r--source3/smbd/message.c13
-rw-r--r--source3/smbd/negprot.c5
-rw-r--r--source3/smbd/trans2.c24
5 files changed, 40 insertions, 22 deletions
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index 413b916f7b..d6c76c54c1 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -1896,6 +1896,7 @@ static bool api_RNetShareAdd(connection_struct *conn,uint16 vuid,
unsigned int offset;
int snum;
int res = ERRunsup;
+ size_t converted_size;
if (!str1 || !str2 || !p) {
return False;
@@ -1956,7 +1957,13 @@ static bool api_RNetShareAdd(connection_struct *conn,uint16 vuid,
return False;
}
- pull_ascii_talloc(talloc_tos(), &pathname, offset? (data+offset) : "");
+ if (!pull_ascii_talloc(talloc_tos(), &pathname,
+ offset ? (data+offset) : "", &converted_size))
+ {
+ DEBUG(0,("api_RNetShareAdd: pull_ascii_talloc failed: %s",
+ strerror(errno)));
+ }
+
if (!pathname) {
return false;
}
diff --git a/source3/smbd/mangle_hash.c b/source3/smbd/mangle_hash.c
index 1dc9c67dcc..69ecf77834 100644
--- a/source3/smbd/mangle_hash.c
+++ b/source3/smbd/mangle_hash.c
@@ -294,8 +294,7 @@ static bool is_8_3(const char *fname, bool check_case, bool allow_wildcards,
if (strlen(f) > 12)
return False;
- size = push_ucs2_allocate(&ucs2name, f);
- if (size == (size_t)-1) {
+ if (!push_ucs2_allocate(&ucs2name, f, &size)) {
DEBUG(0,("is_8_3: internal error push_ucs2_allocate() failed!\n"));
goto done;
}
@@ -604,9 +603,11 @@ static bool must_mangle(const char *name,
{
smb_ucs2_t *name_ucs2 = NULL;
NTSTATUS status;
+ size_t converted_size;
+
magic_char = lp_magicchar(p);
- if (push_ucs2_allocate(&name_ucs2, name) == (size_t)-1) {
+ if (!push_ucs2_allocate(&name_ucs2, name, &converted_size)) {
DEBUG(0, ("push_ucs2_allocate failed!\n"));
return False;
}
@@ -637,12 +638,14 @@ static bool hash_name_to_8_3(const char *in,
const struct share_params *p)
{
smb_ucs2_t *in_ucs2 = NULL;
+ size_t converted_size;
+
magic_char = lp_magicchar(p);
DEBUG(5,("hash_name_to_8_3( %s, cache83 = %s)\n", in,
cache83 ? "True" : "False"));
- if (push_ucs2_allocate(&in_ucs2, in) == (size_t)-1) {
+ if (!push_ucs2_allocate(&in_ucs2, in, &converted_size)) {
DEBUG(0, ("push_ucs2_allocate failed!\n"));
return False;
}
diff --git a/source3/smbd/message.c b/source3/smbd/message.c
index a870f03df9..62df5c37eb 100644
--- a/source3/smbd/message.c
+++ b/source3/smbd/message.c
@@ -45,7 +45,7 @@ static void msg_deliver(struct msg_state *state)
int i;
int fd;
char *msg;
- int len;
+ size_t len;
ssize_t sz;
fstring alpha_buf;
char *s;
@@ -72,18 +72,17 @@ static void msg_deliver(struct msg_state *state)
* Incoming message is in DOS codepage format. Convert to UNIX.
*/
- len = convert_string_talloc(
- talloc_tos(), CH_DOS, CH_UNIX, state->msg,
- talloc_get_size(state->msg), (void *)&msg, true);
-
- if (len == -1) {
+ if (!convert_string_talloc(talloc_tos(), CH_DOS, CH_UNIX, state->msg,
+ talloc_get_size(state->msg), (void *)&msg,
+ &len, true)) {
DEBUG(3, ("Conversion failed, delivering message in DOS "
"codepage format\n"));
msg = state->msg;
}
for (i = 0; i < len; i++) {
- if ((msg[i] == '\r') && (i < (len-1)) && (msg[i+1] == '\n')) {
+ if ((msg[i] == '\r') &&
+ (i < (len-1)) && (msg[i+1] == '\n')) {
continue;
}
sz = write(fd, &msg[i], 1);
diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c
index 9f56949eeb..84f111fb02 100644
--- a/source3/smbd/negprot.c
+++ b/source3/smbd/negprot.c
@@ -516,6 +516,7 @@ void reply_negprot(struct smb_request *req)
int num_cliprotos;
char **cliprotos;
int i;
+ size_t converted_size;
static bool done_negprot = False;
@@ -555,8 +556,8 @@ void reply_negprot(struct smb_request *req)
cliprotos = tmp;
- if (pull_ascii_talloc(cliprotos, &cliprotos[num_cliprotos], p)
- == (size_t)-1) {
+ if (!pull_ascii_talloc(cliprotos, &cliprotos[num_cliprotos], p,
+ &converted_size)) {
DEBUG(0, ("pull_ascii_talloc failed\n"));
TALLOC_FREE(cliprotos);
reply_nterror(req, NT_STATUS_NO_MEMORY);
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index d5435533f9..72688bbd66 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -178,7 +178,7 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
char *p;
char **names, **tmp;
size_t num_names;
- ssize_t sizeret;
+ ssize_t sizeret = -1;
if (!lp_ea_support(SNUM(conn))) {
*pnames = NULL;
@@ -504,7 +504,7 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp, const char *fname, s
static struct ea_list *read_ea_name_list(TALLOC_CTX *ctx, const char *pdata, size_t data_size)
{
struct ea_list *ea_list_head = NULL;
- size_t offset = 0;
+ size_t converted_size, offset = 0;
while (offset + 2 < data_size) {
struct ea_list *eal = TALLOC_ZERO_P(ctx, struct ea_list);
@@ -522,7 +522,11 @@ static struct ea_list *read_ea_name_list(TALLOC_CTX *ctx, const char *pdata, siz
if (pdata[offset + namelen] != '\0') {
return NULL;
}
- pull_ascii_talloc(ctx, &eal->ea.name, &pdata[offset]);
+ if (!pull_ascii_talloc(ctx, &eal->ea.name, &pdata[offset],
+ &converted_size)) {
+ DEBUG(0,("read_ea_name_list: pull_ascii_talloc "
+ "failed: %s", strerror(errno)));
+ }
if (!eal->ea.name) {
return NULL;
}
@@ -544,6 +548,7 @@ struct ea_list *read_ea_list_entry(TALLOC_CTX *ctx, const char *pdata, size_t da
struct ea_list *eal = TALLOC_ZERO_P(ctx, struct ea_list);
uint16 val_len;
unsigned int namelen;
+ size_t converted_size;
if (!eal) {
return NULL;
@@ -565,7 +570,10 @@ struct ea_list *read_ea_list_entry(TALLOC_CTX *ctx, const char *pdata, size_t da
if (pdata[namelen + 4] != '\0') {
return NULL;
}
- pull_ascii_talloc(ctx, &eal->ea.name, pdata + 4);
+ if (!pull_ascii_talloc(ctx, &eal->ea.name, pdata + 4, &converted_size)) {
+ DEBUG(0,("read_ea_list_entry: pull_ascii_talloc failed: %s",
+ strerror(errno)));
+ }
if (!eal->ea.name) {
return NULL;
}
@@ -3665,10 +3673,10 @@ static NTSTATUS marshall_stream_info(unsigned int num_streams,
size_t namelen;
smb_ucs2_t *namebuf;
- namelen = push_ucs2_talloc(talloc_tos(), &namebuf,
- streams[i].name);
-
- if ((namelen == (size_t)-1) || (namelen <= 2)) {
+ if (!push_ucs2_talloc(talloc_tos(), &namebuf,
+ streams[i].name, &namelen) ||
+ namelen <= 2)
+ {
return NT_STATUS_INVALID_PARAMETER;
}