summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-07-02 00:33:15 +0000
committerJeremy Allison <jra@samba.org>2001-07-02 00:33:15 +0000
commit82b76931cb62ea952fb0a4091880a8e0188530c8 (patch)
treedd6a1b5af382cf619f53c78b27df4b3874c10f41
parentef6c9d7425be907230eb533fbbe2e6ac150a0bbd (diff)
downloadsamba-82b76931cb62ea952fb0a4091880a8e0188530c8.tar.gz
samba-82b76931cb62ea952fb0a4091880a8e0188530c8.tar.bz2
samba-82b76931cb62ea952fb0a4091880a8e0188530c8.zip
Insure caught the fact that PTRDIFFs were being done between two unrelated
pointers. Jeremy. (This used to be commit 15c64199cb29e2fca6ee7353673dbb3f962e0e24)
-rw-r--r--source3/libsmb/clifile.c2
-rw-r--r--source3/libsmb/clistr.c20
2 files changed, 17 insertions, 5 deletions
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 42454b306f..2c4eef9bbe 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -243,7 +243,7 @@ int cli_nt_create_full(struct cli_state *cli, char *fname, uint32 DesiredAccess,
p = smb_buf(cli->outbuf);
/* this alignment and termination is critical for netapp filers. Don't change */
- p += clistr_align(cli, p, STR_CONVERT);
+ p += clistr_align_out(cli, p, STR_CONVERT);
len = clistr_push(cli, p, fname, -1, STR_CONVERT);
p += len;
SSVAL(cli->outbuf,smb_ntcreate_NameLength, len);
diff --git a/source3/libsmb/clistr.c b/source3/libsmb/clistr.c
index 762a24c22c..6dd3b751b4 100644
--- a/source3/libsmb/clistr.c
+++ b/source3/libsmb/clistr.c
@@ -50,7 +50,7 @@ int clistr_push(struct cli_state *cli, void *dest, const char *src, int dest_len
dest_len = sizeof(pstring);
}
- if (clistr_align(cli, dest, flags)) {
+ if (clistr_align_out(cli, dest, flags)) {
*(char *)dest = 0;
dest = (void *)((char *)dest + 1);
dest_len--;
@@ -101,7 +101,7 @@ int clistr_pull(struct cli_state *cli, char *dest, const void *src, int dest_len
dest_len = sizeof(pstring);
}
- if (clistr_align(cli, src, flags)) {
+ if (clistr_align_in(cli, src, flags)) {
src = (const void *)((const char *)src + 1);
if (src_len > 0) src_len--;
}
@@ -146,8 +146,20 @@ return an alignment of either 0 or 1
if unicode is not negotiated then return 0
otherwise return 1 if offset is off
****************************************************************************/
-int clistr_align(struct cli_state *cli, const void *p, int flags)
+static int clistr_align(struct cli_state *cli, char *buf, const void *p, int flags)
{
if ((flags & STR_NOALIGN) || !UNICODE_FLAG(cli, flags)) return 0;
- return PTR_DIFF(p, cli->outbuf) & 1;
+ return PTR_DIFF(p, buf) & 1;
}
+
+int clistr_align_out(struct cli_state *cli, const void *p, int flags)
+{
+ return clistr_align(cli, cli->outbuf, p, flags);
+}
+
+int clistr_align_in(struct cli_state *cli, const void *p, int flags)
+{
+ return clistr_align(cli, cli->inbuf, p, flags);
+}
+
+