<html><head></head><body>Hi,<br><br>So if the user specifically requests a long file name on a system that supports it, you'll truncate anyway, and thus break scripts or third party apps that wrap VLC?<br><br>This makes no sense to me.<br><br><div class="gmail_quote">Le 16 décembre 2019 15:15:49 GMT+02:00, Thomas Guillem <thomas@gllm.fr> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">This fixes sout chain fail when the input path/url is too long. This can easily<br>happen when the source is a network url that can be longer than local pathes.<hr> modules/access_output/file.c | 32 ++++++++++++++++++++++++++++++++<br> 1 file changed, 32 insertions(+)<br><br>diff --git a/modules/access_output/file.c b/modules/access_output/file.c<br>index c983e3a8f09..86fe032dd0b 100644<br>--- a/modules/access_output/file.c<br>+++ b/modules/access_output/file.c<br>@@ -36,6 +36,8 @@<br> #include <errno.h><br> #include <sys/stat.h><br> #include <unistd.h><br>+#include <limits.h><br>+#include <string.h><br> #ifdef __OS2__<br> # include <io.h> /* setmode() */<br> #endif<br>@@ -298,6 +300,36 @@ static int Open( vlc_object_t *p_this )<br> if (var_GetBool (p_access, SOUT_CFG_PREFIX"sync"))<br> flags |= O_SYNC;<br> #endif<br>+<br>+#ifndef NAME_MAX<br>+ #ifdef (MAX_PATH)<br>+ #define NAME_MAX MAX_PATH /* win32 */<br>+ #else<br>+ #define NAME_MAX 256<br>+ #endif<br>+#endif<br>+ /* Check if the path need to be truncated */<br>+ size_t path_len = strlen(path);<br>+ if (path_len > NAME_MAX)<br>+ {<br>+ /* Allocate the buf if needed since p_access->psz_path is const */<br>+ if (path == p_access->psz_path)<br>+ {<br>+ buf = strdup(path);<br>+ if (!buf)<br>+ return VLC_ENOMEM;<br>+ path = buf;<br>+ }<br>+<br>+ /* Don't loose the extension if any */<br>+ const char *ext = strrchr(path, '.');<br>+ size_t ext_len = ext ? strlen(ext) : 0;<br>+ if (ext && ext_len <= 4)<br>+ strcpy(&buf[NAME_MAX - ext_len - 1], ext);<br>+ else<br>+ buf[NAME_MAX] = 0;<br>+ }<br>+<br> do<br> {<br> fd = vlc_open (path, flags, 0666);</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>