summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-04-16 10:40:23 +0000
committerAndrew Tridgell <tridge@samba.org>2002-04-16 10:40:23 +0000
commit02f84c6bd0c06c3dacc93d6413d6645367f42744 (patch)
tree11ab6017e80520c47995b4e46ca79e175ba80268
parente7b729e0d9d6264e85be042b16aa6aee0648fcfd (diff)
downloadsamba-02f84c6bd0c06c3dacc93d6413d6645367f42744.tar.gz
samba-02f84c6bd0c06c3dacc93d6413d6645367f42744.tar.bz2
samba-02f84c6bd0c06c3dacc93d6413d6645367f42744.zip
i forgot to commit these parts of the string handling patch earlier. Sorry.
(This used to be commit bac0093a9713416b1679d1bc167b70f02b06ef78)
-rw-r--r--source3/include/smb_macros.h5
-rw-r--r--source3/lib/charcnv.c10
2 files changed, 9 insertions, 6 deletions
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index c19be784a1..27a5961651 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -169,9 +169,12 @@
#define SMB_ROUNDUP_ALLOCATION(s) ((s) ? (SMB_ROUNDUP((SMB_OFF_T)((s)+1), ((SMB_OFF_T)SMB_ROUNDUP_ALLOCATION_SIZE))) : 0 )
/* Extra macros added by Ying Chen at IBM - speed increase by inlining. */
-#define smb_buf(buf) (buf + smb_size + CVAL(buf,smb_wct)*2)
+#define smb_buf(buf) ((buf) + smb_size + CVAL(buf,smb_wct)*2)
#define smb_buflen(buf) (SVAL(buf,smb_vwv0 + (int)CVAL(buf, smb_wct)*2))
+/* the remaining number of bytes in smb buffer 'buf' from pointer 'p'. */
+#define smb_bufrem(buf, p) (smb_buflen(buf)-PTR_DIFF(p, smb_buf(buf)))
+
/* Note that chain_size must be available as an extern int to this macro. */
#define smb_offset(p,buf) (PTR_DIFF(p,buf+4) + chain_size)
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index cdfca8eb97..be7701237e 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -354,7 +354,7 @@ int pull_ascii(char *dest, const void *src, int dest_len, int src_len, int flags
dest_len = sizeof(pstring);
}
- if (flags & STR_TERMINATE) src_len = strlen(src)+1;
+ if (src_len == -1 && (flags & STR_TERMINATE)) src_len = strlen(src)+1;
ret = convert_string(CH_DOS, CH_UNIX, src, src_len, dest, dest_len);
@@ -525,7 +525,7 @@ copy a string from a ucs2 source to a unix char* destination
flags can have:
STR_TERMINATE means the string in src is null terminated
STR_NOALIGN means don't try to align
-if STR_TERMINATE is set then src_len is ignored
+if STR_TERMINATE is set then src_len is ignored if it is -1
src_len is the length of the source area in bytes
return the number of bytes occupied by the string in src
the resulting string in "dest" is always null terminated
@@ -543,7 +543,7 @@ int pull_ucs2(const void *base_ptr, char *dest, const void *src, int dest_len, i
if (src_len > 0) src_len--;
}
- if (flags & STR_TERMINATE) src_len = strlen_w(src)*2+2;
+ if (src_len == -1 && (flags & STR_TERMINATE)) src_len = strlen_w(src)*2+2;
/* ucs2 is always a multiple of 2 bytes */
src_len &= ~1;
@@ -609,7 +609,7 @@ int pull_utf8(char *dest, const void *src, int dest_len, int src_len, int flags)
dest_len = sizeof(pstring);
}
- if (flags & STR_TERMINATE) src_len = strlen(src)+1;
+ if (src_len == -1 && (flags & STR_TERMINATE)) src_len = strlen(src)+1;
ret = convert_string(CH_UTF8, CH_UNIX, src, src_len, dest, dest_len);
if (dest_len) dest[MIN(ret, dest_len-1)] = 0;
@@ -687,7 +687,7 @@ flags can have:
STR_UNICODE means to force as unicode
STR_ASCII use ascii even with unicode packet
STR_NOALIGN means don't do alignment
-if STR_TERMINATE is set then src_len is ignored
+if STR_TERMINATE is set then src_len is ignored is it is -1
src_len is the length of the source area in bytes
return the number of bytes occupied by the string in src
the resulting string in "dest" is always null terminated