Public feed #894198

Something

public text v1 · immutable
Raw Edit
·published 2008-02-06 19:33 UTC
rendered paste body
+			if (myenforced) {
+ 
+				/* We don't need to allocate more space than just the
+				length of (peer->name) for ext as we will cut the
+				channel name's ending before copying into ext */
+
+				ext = alloca(strlen(peer->name));
+
+ 				/* This one adds 3 characters in length to the colon
+				delimited list. Two characters are for the colons themselves
+				and the other is for the \0 character. */
+
+				form_enforced = alloca(strlen(myenforced) + 3);
+				
+				/* Now we add the colons to the string, one at the
+				beginning, one at the end, to make sure we
+				have properly colon delimited interface names in the
+				form_enforced string */
+				strcpy(form_enforced, ":");
+				strcat(form_enforced, myenforced);
+				strcat(form_enforced, ":");
+				
+				/* Putting the channel name into a temporary buffer, so we 
+				can add the colon at the beginning, for proper delimitation, and
+				preventing rather serious mistakes. */
+				buffer = ast_strdupa(peer->name);
+				
+				/* We find the end of the peer->name, which includes a bunch of
+				crap as some channel id or something, so we waste that, and just
+				keep the peer name proper involved in the conversation */
+				if ((end = strchr(buffer, '-'))) {
+				    *end++ = ':';
+				    *end = '\0';
+				}
+
+				/* Now we add a beginning colon for the proper delimitation, and
+				we add then the peer name itself. We now have a proper peer name
+				delimited on both sides by colons, and this will prevent all future
+				massive fuckups. */
+				strcpy(ext, ":");
+				strcat(ext, buffer);				
+
+				/* Is the peer name we are trying to spy on in the list of allowed
+				interfaces? If it is, then we are good to go. If not, then we are not
+				allowed to spy on that interface, and we let the sucker move on to
+				an interface he has the right to spy on, maybe some other time. */
+				if (strstr(form_enforced, ext))
+					ienf = 1;
+
+			}