[xiph-commits] r11585 - trunk/icecast2yp/src

giles at svn.xiph.org giles at svn.xiph.org
Sun Jun 18 12:44:46 PDT 2006


Author: giles
Date: 2006-06-18 12:44:46 -0700 (Sun, 18 Jun 2006)
New Revision: 11585

Modified:
   trunk/icecast2yp/src/yp_cgi.c
Log:
Only accept streams of type application/ogg 
Also, avoid openning a db connection until after some checks for valid input are made.


Modified: trunk/icecast2yp/src/yp_cgi.c
===================================================================
--- trunk/icecast2yp/src/yp_cgi.c	2006-06-18 14:45:07 UTC (rev 11584)
+++ trunk/icecast2yp/src/yp_cgi.c	2006-06-18 19:44:46 UTC (rev 11585)
@@ -6,7 +6,7 @@
 
 int main(int argc, char * argv[])
 {
-	int res;
+	int 	res = 0;
 	int	ret = 0;
 	int	ok = 0;
 	int	action = NO_ACTION;
@@ -73,21 +73,6 @@
 		goto endofcall;
 	}
 
-	/* Was there an error initializing the CGI??? */
-/*
-
-	if (res != CGIERR_NONE) {
-		sprintf(msg, "Error # %d: %s<p>\n", res, cgi_strerror(res));
-		sendYPResponse(0, msg, ICECAST2_RESPONSE);
-	}
-*/
-	res = connectToDB();
-	if (!res) {
-		sendYPResponse(0, "Error connecting to database", ICECAST2_RESPONSE);
-		goto endofcall;
-	}
-
-	Log(LOG_DEBUG, "Connected to DB");
 	/* Grab some fields from an HTML form and display them: */
 
 	if (cgi_param("action") != NULL) {
@@ -325,6 +310,19 @@
 			}
 		}
 		Log(LOG_DEBUG, "Done getting parameters");
+		Log(LOG_DEBUG, "Limiting by stream mime-type");
+		if (strncmp(server_type, "application/ogg", strlen("application/ogg"))) {
+			sendYPResponse(0, "We only accept Ogg stream listings", ICECAST2_RESPONSE);
+			goto endofcall;
+		}
+
+		res = connectToDB();
+		if (!res) {
+			sendYPResponse(0, "Error connecting to database", ICECAST2_RESPONSE);
+			goto endofcall;
+		}
+	Log(LOG_DEBUG, "Connected to DB");
+
 		if (action == ADD) {
 			Log(LOG_DEBUG, "Checking server name");
 			if (strlen(server_name) == 0) {
@@ -424,8 +422,10 @@
 
 	cgi_end();
 
-	Log(LOG_DEBUG, "Disconnecting from DB");
-	disconnectFromDB();
+	if (!res) {
+		Log(LOG_DEBUG, "Disconnecting from DB");
+		disconnectFromDB();
+	}
 
 	Log(LOG_DEBUG, "Ending execution");
 



More information about the commits mailing list