[PATCH] librtp: Accept both LF and CRLF after SDP header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

> RFC 4556 specifies that
> 
> > The sequence CRLF (0x0d0a) is used to end a record, although parsers SHOULD be
> > tolerant and also accept records terminated with a single newline character.
> 
> PulseAudio is only looking for LF characters, which leads to a few
> problems:

ok, this could be improved

> 1. If the version header ends with CRLF, the packet is rejected. This
> has previously been reported in
> http://lists.freedesktop.org/archives/pulseaudio-discuss/2012-July/014159.html

please include a link to that report in the patch description

> 2. The packets generated by module-rtp-send don't follow the RFC.

any further information?

> 3. Any CR characters are included in the values that are read. This can
> be seen when logging to console in the form of messages like
> 
> > )" [pulseaudio] sink-input.c: Freeing input 0 "RTP Stream (foo
> 
> . Note how the embedded carriage return leads to the message start being
> overwritten.
 
ok, not nice

> As for my patch, please disregard it since it's wrong :). I'll come back
> later with a fixed version.

go for it!

you want to accept CR/LF after each line, not just the first one?

> > why is this patch needed?

> > > ---
> > >  src/modules/rtp/sdp.c | 7 ++++++-
> > >  src/modules/rtp/sdp.h | 2 +-
> > >  2 files changed, 7 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/src/modules/rtp/sdp.c b/src/modules/rtp/sdp.c
> > > index e47a41b..904c35f 100644
> > > --- a/src/modules/rtp/sdp.c
> > > +++ b/src/modules/rtp/sdp.c
> > > @@ -66,7 +66,7 @@ char *pa_sdp_build(int af, const void *src, const void *dst, const char *name, u
> > >      pa_assert_se(inet_ntop(af, dst, buf_dst, sizeof(buf_dst)));
> > >  
> > >      return pa_sprintf_malloc(
> > > -            PA_SDP_HEADER
> > > +            PA_SDP_HEADER "\n"
> > >              "o=%s %lu 0 IN %s %s\n"
> > >              "s=%s\n"
> > >              "c=IN %s %s\n"
> > > @@ -136,6 +136,11 @@ pa_sdp_info *pa_sdp_parse(const char *t, pa_sdp_info *i, int is_goodbye) {
> > >  
> > >      t += sizeof(PA_SDP_HEADER)-1;
> > >  
> > > +    if (*t == '\r')
> > > +        t++;
> > > +    if (*t == '\n')
> > > +        t++;
> > > +
> > >      while (*t) {
> > >          size_t l;
> > >  
> > > diff --git a/src/modules/rtp/sdp.h b/src/modules/rtp/sdp.h
> > > index 4cb3b20..e13ca8a 100644
> > > --- a/src/modules/rtp/sdp.h
> > > +++ b/src/modules/rtp/sdp.h
> > > @@ -28,7 +28,7 @@
> > >  
> > >  #include <pulse/sample.h>
> > >  
> > > -#define PA_SDP_HEADER "v=0\n"
> > > +#define PA_SDP_HEADER "v=0"
> > >  
> > >  typedef struct pa_sdp_info {
> > >      char *origin;
> > > 
> > 
> > -- 
> > 
> > Peter Meerwald
> > +43-664-2444418 (mobile)
> 

-- 

Peter Meerwald
+43-664-2444418 (mobile)


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux