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

Laurențiu Nicola lnicola at dend.ro
Thu Dec 26 15:53:52 PST 2013


Hello Peter,

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:

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
.
2. The packets generated by module-rtp-send don't follow the RFC.
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.

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

Laurentiu

On Fri, Dec 27, 2013, at 12:14 AM, Peter Meerwald wrote:
> Hi Laurentiu,
> 
> why is this patch needed?
> 
> p.
> 
> > ---
> >  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)


More information about the pulseaudio-discuss mailing list