[vlc-commits] unc: chop before rather than after string copy
Rémi Denis-Courmont
git at videolan.org
Sun Feb 23 15:12:02 CET 2020
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Feb 23 16:09:32 2020 +0200| [6e49d43e30d6a024cf63c6fdc130d1899adc0b18] | committer: Rémi Denis-Courmont
unc: chop before rather than after string copy
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6e49d43e30d6a024cf63c6fdc130d1899adc0b18
---
modules/access/unc.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/modules/access/unc.c b/modules/access/unc.c
index fbb3a58240..92a390535e 100644
--- a/modules/access/unc.c
+++ b/modules/access/unc.c
@@ -56,14 +56,18 @@ static void Win32AddConnection(stream_t *access, const char *server,
{
char *remote_name;
- if (asprintf(&remote_name, "\\\\%s\\%s", server,
- (share != NULL) ? share + 1 /* skip leading '/' */: "") < 0)
- return;
-
- /* remove trailings '/' */
- char *delim = strchr(remote_name, '/');
- if (delim != NULL)
- *delim = '\0';
+ if (share != NULL)
+ { /* skip leading and remove trailing slashes */
+ int slen = strcspn(++share, "/");
+
+ if (asprintf(&remote_name, "\\\\%s\\%.*s", server, slen, share) < 0)
+ return;
+ }
+ else
+ {
+ if (asprintf(&remote_name, "\\\\%s\\", server) < 0)
+ return;
+ }
NETRESOURCE net_resource = {
.dwType = RESOURCETYPE_DISK,
More information about the vlc-commits
mailing list