fix for issue 56, Wrong icecast2 password isn't properly reporte, by flip.roque

This commit is contained in:
rafael@riseup.net 2012-01-19 01:07:30 +00:00
parent c4677ec32e
commit c1d152ca8a
2 changed files with 14 additions and 0 deletions

View File

@ -199,10 +199,16 @@ IceCast :: sendLogin ( void ) throw ( Exception )
/* read the anticipated response: "OK" */
len = source->read( resp, STRBUF_SIZE);
reportEvent(5,resp);
if ( Util::strEq( resp, "ERROR - Bad Password",20) ) {
throw Exception( __FILE__, __LINE__,
"Icecast - wrong password");
}
if ( Util::strEq( resp, "ERROR - Mount Point Taken or Inv",32) ) {
throw Exception( __FILE__, __LINE__,
"Icecast - Mount point taken or invalid");
}
if ( len < 2 || resp[0] != 'O' || resp[1] != 'K' ) {
return false;
}

View File

@ -81,6 +81,7 @@ static const char fileid[] = "$Id$";
*----------------------------------------------------------------------------*/
static const char responseOK[] = "HTTP/1.0 200";
static const char responseWrongPasswd[] = "HTTP/1.0 401";
static const char responseForbidden[] = "HTTP/1.0 403";
/* =============================================== local function prototypes */
@ -247,11 +248,18 @@ IceCast2 :: sendLogin ( void ) throw ( Exception )
}
resp[lenExpected] = 0;
reportEvent(5,resp);
if ( Util::strEq( resp, responseWrongPasswd) ) {
throw Exception( __FILE__, __LINE__,
"Icecast2 - wrong password");
}
if ( Util::strEq( resp, responseForbidden) ) {
throw Exception( __FILE__, __LINE__,
"Icecast2 - forbidden. Is the mountpoint occupied, or maximum sources reached?");
}
if ( !Util::strEq( resp, responseOK) ) {
return false;
}