[vlc-commits] contrib: smb2: fix getlogin_r() patch
Thomas Guillem
git at videolan.org
Tue Aug 13 18:08:11 CEST 2019
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Aug 12 10:06:20 2019 +0200| [a2289a28a997fd19bf0e2611f6a13efa9929e20a] | committer: Thomas Guillem
contrib: smb2: fix getlogin_r() patch
cf. libsmb2 upstream.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a2289a28a997fd19bf0e2611f6a13efa9929e20a
---
contrib/src/smb2/0003-Fix-getlogin-usage.patch | 32 +++++++++++++++-------
...2_destroy_context-fix-possible-null-deref.patch | 8 +++---
2 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/contrib/src/smb2/0003-Fix-getlogin-usage.patch b/contrib/src/smb2/0003-Fix-getlogin-usage.patch
index e639596a7b..91776d9f5f 100644
--- a/contrib/src/smb2/0003-Fix-getlogin-usage.patch
+++ b/contrib/src/smb2/0003-Fix-getlogin-usage.patch
@@ -1,4 +1,4 @@
-From 4801820ba947ca895721ac0a198362409cd94d69 Mon Sep 17 00:00:00 2001
+From 434a880dc7f304eafb2377e26d47d93187109b14 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas at gllm.fr>
Date: Tue, 30 Jul 2019 18:02:14 +0200
Subject: [PATCH 3/4] Fix getlogin() usage
@@ -8,32 +8,44 @@ could be overwritten on subsequent calls).
Also check for error and use "Guest" as a fallback.
---
- lib/init.c | 10 ++++++----
- 1 file changed, 6 insertions(+), 4 deletions(-)
+ lib/init.c | 20 ++++++++++++++++----
+ 1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/lib/init.c b/lib/init.c
-index eab69a5..3c01774 100644
+index eab69a5..4387cd0 100644
--- a/lib/init.c
+++ b/lib/init.c
-@@ -52,7 +52,7 @@
+@@ -52,17 +52,27 @@
#define MAX_URL_SIZE 256
#ifdef _MSC_VER
-#define getlogin() "Guest"
-+#define getlogin_r() ENXIO
++#include <errno.h>
++#define getlogin_r(a,b) ENXIO
#define random rand
#define getpid GetCurrentProcessId
#endif // _MSC_VER
-@@ -60,7 +60,7 @@
+
#ifdef ESP_PLATFORM
++#include <errno.h>
#include <esp_system.h>
#define random esp_random
-#define getlogin() "Guest"
-+#define getlogin_r() ENXIO
++#define getlogin_r(a,b) ENXIO
#endif
++#ifdef __ANDROID__
++#include <errno.h>
++// getlogin_r() was added in API 28
++#if __ANDROID_API__ < 28
++#define getlogin_r(a,b) ENXIO
++#endif
++#endif // __ANDROID__
++
static int
-@@ -206,7 +206,8 @@ void smb2_destroy_url(struct smb2_url *url)
+ smb2_parse_args(struct smb2_context *smb2, const char *args)
+ {
+@@ -206,7 +216,8 @@ void smb2_destroy_url(struct smb2_url *url)
struct smb2_context *smb2_init_context(void)
{
struct smb2_context *smb2;
@@ -43,7 +55,7 @@ index eab69a5..3c01774 100644
smb2 = malloc(sizeof(struct smb2_context));
if (smb2 == NULL) {
-@@ -214,7 +215,8 @@ struct smb2_context *smb2_init_context(void)
+@@ -214,7 +225,8 @@ struct smb2_context *smb2_init_context(void)
}
memset(smb2, 0, sizeof(struct smb2_context));
diff --git a/contrib/src/smb2/0004-smb2_destroy_context-fix-possible-null-deref.patch b/contrib/src/smb2/0004-smb2_destroy_context-fix-possible-null-deref.patch
index f5327b64cb..ec8f9331b3 100644
--- a/contrib/src/smb2/0004-smb2_destroy_context-fix-possible-null-deref.patch
+++ b/contrib/src/smb2/0004-smb2_destroy_context-fix-possible-null-deref.patch
@@ -1,4 +1,4 @@
-From ada4e70f9aee53421aba23a9a4dbb947470d7c5d Mon Sep 17 00:00:00 2001
+From 6e2126a854292621548948a3d30e6023943d7c99 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas at gllm.fr>
Date: Thu, 8 Aug 2019 15:18:31 +0200
Subject: [PATCH 4/4] smb2_destroy_context: fix possible null-deref
@@ -10,10 +10,10 @@ This could happen when the smb2_close_async() command was aborted
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/init.c b/lib/init.c
-index 3c01774..0a279d0 100644
+index 4387cd0..03903fb 100644
--- a/lib/init.c
+++ b/lib/init.c
-@@ -245,14 +245,6 @@ void smb2_destroy_context(struct smb2_context *smb2)
+@@ -255,14 +255,6 @@ void smb2_destroy_context(struct smb2_context *smb2)
smb2->fd = -1;
}
@@ -28,7 +28,7 @@ index 3c01774..0a279d0 100644
while (smb2->outqueue) {
struct smb2_pdu *pdu = smb2->outqueue;
-@@ -273,6 +265,14 @@ void smb2_destroy_context(struct smb2_context *smb2)
+@@ -283,6 +275,14 @@ void smb2_destroy_context(struct smb2_context *smb2)
smb2->pdu = NULL;
}
More information about the vlc-commits
mailing list