The Samba-Bugzilla – Attachment 18635 Details for
Bug 15849
lease code is not endian-safe
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch for 4.22
endian.patch (text/plain), 6.77 KB, created by
Björn Jacke
on 2025-04-17 12:29:05 UTC
(
hide
)
Description:
patch for 4.22
Filename:
MIME Type:
Creator:
Björn Jacke
Created:
2025-04-17 12:29:05 UTC
Size:
6.77 KB
patch
obsolete
>From 7768172e78f9e081bdd57c3c78dfd1d56dcb833f Mon Sep 17 00:00:00 2001 >From: Stefan Metzmacher <metze@samba.org> >Date: Wed, 16 Apr 2025 15:18:12 +0200 >Subject: [PATCH 1/4] libcli/smb: convert smb2_lease_pull() to PULL_LE_U* >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15849 > >Signed-off-by: Stefan Metzmacher <metze@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >Reviewed-by: Björn Jacke <bjacke@samba.org> >(cherry picked from commit 31ebf2cd1daeed25fab92ef71f7591fea8c92226) >--- > libcli/smb/smb2_lease.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > >diff --git a/libcli/smb/smb2_lease.c b/libcli/smb/smb2_lease.c >index d28477b1911..02b0cfa8dc5 100644 >--- a/libcli/smb/smb2_lease.c >+++ b/libcli/smb/smb2_lease.c >@@ -45,20 +45,20 @@ ssize_t smb2_lease_pull(const uint8_t *buf, size_t len, > } > > memcpy(&lease->lease_key, buf, 16); >- lease->lease_state = IVAL(buf, 16); >+ lease->lease_state = PULL_LE_U32(buf, 16); > lease->lease_version = version; > > switch (version) { > case 1: > break; > case 2: >- lease->lease_flags = IVAL(buf, 20); >+ lease->lease_flags = PULL_LE_U32(buf, 20); >+ lease->lease_duration = PULL_LE_U64(buf, 24); > lease->lease_flags &= SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET; > if (lease->lease_flags & SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET) { > memcpy(&lease->parent_lease_key, buf+32, 16); > } >- lease->lease_duration = BVAL(buf, 24); >- lease->lease_epoch = SVAL(buf, 48); >+ lease->lease_epoch = PULL_LE_U16(buf, 48); > break; > } > >-- >2.41.0 > > >From b907a0b5d53c8f041eea959f6536145fb6efd3bb Mon Sep 17 00:00:00 2001 >From: Stefan Metzmacher <metze@samba.org> >Date: Wed, 16 Apr 2025 15:18:12 +0200 >Subject: [PATCH 2/4] libcli/smb: make the last 2 reserved bytes explicit in > smb2_lease_push() >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15849 > >Signed-off-by: Stefan Metzmacher <metze@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >Reviewed-by: Björn Jacke <bjacke@samba.org> >(cherry picked from commit cbe438eb1a3c44f5cd46c5e685da9964da64f892) >--- > libcli/smb/smb2_lease.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > >diff --git a/libcli/smb/smb2_lease.c b/libcli/smb/smb2_lease.c >index 02b0cfa8dc5..4631b867949 100644 >--- a/libcli/smb/smb2_lease.c >+++ b/libcli/smb/smb2_lease.c >@@ -87,7 +87,8 @@ bool smb2_lease_push(const struct smb2_lease *lease, uint8_t *buf, size_t len) > > if (version == 2) { > memcpy(&buf[32], &lease->parent_lease_key, 16); >- SIVAL(buf, 48, lease->lease_epoch); >+ SSVAL(buf, 48, lease->lease_epoch); >+ SSVAL(buf, 50, 0); /* reserved */ > } > > return true; >-- >2.41.0 > > >From fbdd93870e49e024822ef775e2fb44aff7cb2805 Mon Sep 17 00:00:00 2001 >From: Stefan Metzmacher <metze@samba.org> >Date: Wed, 16 Apr 2025 15:18:12 +0200 >Subject: [PATCH 3/4] libcli/smb: convert smb2_lease_push() to PUSH_LE_U* >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15849 > >Signed-off-by: Stefan Metzmacher <metze@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >Reviewed-by: Björn Jacke <bjacke@samba.org> >(cherry picked from commit edf9cf4b29dab78f63eec8391cd1cd9eef861612) >--- > libcli/smb/smb2_lease.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > >diff --git a/libcli/smb/smb2_lease.c b/libcli/smb/smb2_lease.c >index 4631b867949..3574fffba32 100644 >--- a/libcli/smb/smb2_lease.c >+++ b/libcli/smb/smb2_lease.c >@@ -81,14 +81,14 @@ bool smb2_lease_push(const struct smb2_lease *lease, uint8_t *buf, size_t len) > } > > memcpy(&buf[0], &lease->lease_key, 16); >- SIVAL(buf, 16, lease->lease_state); >- SIVAL(buf, 20, lease->lease_flags); >- SBVAL(buf, 24, lease->lease_duration); >+ PUSH_LE_U32(buf, 16, lease->lease_state); >+ PUSH_LE_U32(buf, 20, lease->lease_flags); >+ PUSH_LE_U64(buf, 24, lease->lease_duration); > > if (version == 2) { > memcpy(&buf[32], &lease->parent_lease_key, 16); >- SSVAL(buf, 48, lease->lease_epoch); >- SSVAL(buf, 50, 0); /* reserved */ >+ PUSH_LE_U16(buf, 48, lease->lease_epoch); >+ PUSH_LE_U16(buf, 50, 0); /* reserved */ > } > > return true; >-- >2.41.0 > > >From f8bafe438744c823d85906bb3f4469135e2e87a6 Mon Sep 17 00:00:00 2001 >From: Stefan Metzmacher <metze@samba.org> >Date: Wed, 16 Apr 2025 15:18:12 +0200 >Subject: [PATCH 4/4] libcli/smb: make smb2_lease_{pull,push} endian safe >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >smbd_smb2_send_lease_break() is already endian safe, >which means we'll get a mismatch on big endian systems, >so that smbd_smb2_send_lease_break() sends the lease key >in reversed order. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15849 > >Signed-off-by: Stefan Metzmacher <metze@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >Reviewed-by: Björn Jacke <bjacke@samba.org> > >Autobuild-User(master): Stefan Metzmacher <metze@samba.org> >Autobuild-Date(master): Thu Apr 17 11:30:58 UTC 2025 on atb-devel-224 > >(cherry picked from commit 80d5fa134d51b4b2238f775fea0af3d511bf3144) >--- > libcli/smb/smb2_lease.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > >diff --git a/libcli/smb/smb2_lease.c b/libcli/smb/smb2_lease.c >index 3574fffba32..0fc15e51227 100644 >--- a/libcli/smb/smb2_lease.c >+++ b/libcli/smb/smb2_lease.c >@@ -44,7 +44,8 @@ ssize_t smb2_lease_pull(const uint8_t *buf, size_t len, > return -1; > } > >- memcpy(&lease->lease_key, buf, 16); >+ lease->lease_key.data[0] = PULL_LE_U64(buf, 0); >+ lease->lease_key.data[1] = PULL_LE_U64(buf, 8); > lease->lease_state = PULL_LE_U32(buf, 16); > lease->lease_version = version; > >@@ -56,7 +57,8 @@ ssize_t smb2_lease_pull(const uint8_t *buf, size_t len, > lease->lease_duration = PULL_LE_U64(buf, 24); > lease->lease_flags &= SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET; > if (lease->lease_flags & SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET) { >- memcpy(&lease->parent_lease_key, buf+32, 16); >+ lease->parent_lease_key.data[0] = PULL_LE_U64(buf, 32); >+ lease->parent_lease_key.data[1] = PULL_LE_U64(buf, 40); > } > lease->lease_epoch = PULL_LE_U16(buf, 48); > break; >@@ -80,13 +82,15 @@ bool smb2_lease_push(const struct smb2_lease *lease, uint8_t *buf, size_t len) > return false; > } > >- memcpy(&buf[0], &lease->lease_key, 16); >+ PUSH_LE_U64(buf, 0, lease->lease_key.data[0]); >+ PUSH_LE_U64(buf, 8, lease->lease_key.data[1]); > PUSH_LE_U32(buf, 16, lease->lease_state); > PUSH_LE_U32(buf, 20, lease->lease_flags); > PUSH_LE_U64(buf, 24, lease->lease_duration); > > if (version == 2) { >- memcpy(&buf[32], &lease->parent_lease_key, 16); >+ PUSH_LE_U64(buf, 32, lease->parent_lease_key.data[0]); >+ PUSH_LE_U64(buf, 40, lease->parent_lease_key.data[1]); > PUSH_LE_U16(buf, 48, lease->lease_epoch); > PUSH_LE_U16(buf, 50, 0); /* reserved */ > } >-- >2.41.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
metze
:
review+
Actions:
View
Attachments on
bug 15849
: 18635