[vlc-devel] [PATCH 4/9] raop: Implement options for password

Michael Hanselmann public at hansmi.ch
Sun Jul 26 00:01:48 CEST 2009


On Fri, Jul 24, 2009 at 11:41 AM, <jpd at videolan.org> wrote:
> On Fri, Jul 24, 2009 at 11:24:59AM +0200, Michael Hanselmann wrote:
>> So, the strsep(3) call in my patch just replaces the first occurence
>> of "\r" or "\n" after the password.
>
> Right. But you would only need "\n" if the file is opened in "text"
> mode. And in that case, strlen()-1 would do equally well to find the
> newline if it's there.

It's not equally well. The function should just return the first line,
not just remove the last newline. Here's an interdiff with my latest
changes:

--- a/modules/stream_out/raop.c
+++ b/modules/stream_out/raop.c
@@ -29,6 +29,7 @@
 #endif

 #include <assert.h>
+#include <strings.h>

 #include <gcrypt.h>

@@ -71,7 +72,6 @@ static const char psz_delim_space[] = " ";
 static const char psz_delim_colon[] = ":";
 static const char psz_delim_equal[] = "=";
 static const char psz_delim_semicolon[] = ";";
-static const char psz_delim_linebreak[] = "\r\n";


 /*****************************************************************************
@@ -563,7 +563,7 @@ static char *ReadPasswordFile( vlc_object_t
*p_this, const char *psz_path )
 {
     FILE *p_file = NULL;
     char *psz_password = NULL;
-    char *psz_next;
+    char *psz_newline;
     char ps_buffer[256];

     p_file = utf8_fopen( psz_path, "rt" );
@@ -584,13 +584,12 @@ static char *ReadPasswordFile( vlc_object_t
*p_this, const char *psz_path )
     }

     /* Replace first newline with '\0' */
-    psz_next = ps_buffer;
-    strsep( &psz_next, psz_delim_linebreak );
+    psz_newline = index(ps_buffer, '\n');
+    if ( psz_newline != NULL )
+        *psz_newline = '\0';

     psz_password = strdup( ps_buffer );

-    msg_Info( p_this, "pw='%s'", psz_password );
-
 error:
     if ( p_file != NULL )
         fclose( p_file );


Are you okay with this version? If so I'll resend the full patch.

Regards,
Michael

-- 
http://hansmi.ch/



More information about the vlc-devel mailing list