Browse Source

Removed some redundant shit, also pr0perly check parc at certain points to make sure the params ain't poisuned y0

Wazakindjes 4 years ago
parent
commit
6610fef16f
7 changed files with 52 additions and 51 deletions
  1. 2 3
      malv/m_mshun.c
  2. 1 1
      u4/m_anti_amsg.c
  3. 4 6
      u4/m_denyban.c
  4. 6 3
      u4/m_noinvite.c
  5. 32 32
      u4/m_rtkl.c
  6. 4 3
      uncommon/m_bancheck_access.c
  7. 3 3
      uncommon/m_textshun.c

+ 2 - 3
malv/m_mshun.c

@@ -104,7 +104,7 @@ static char *muhhalp[] = {
 // Dat dere module header
 ModuleHeader MOD_HEADER(m_mshun) = {
 	"m_mshun", // Module name
-	"$Id: v1.01 2017/11/09 Gottem$", // Version
+	"$Id: v1.02 2019/01/24 Gottem$", // Version
 	"Implements an M:Line for special shuns", // Description
 	"3.2-b8-1", // Modversion, not sure wat do
 	NULL
@@ -438,8 +438,7 @@ CMD_FUNC(m_mshun) {
 		return 0;
 	}
 
-	// Need at the very least 1 arg lol
-	if(parc < 2 || !stricmp(parv[1], "help") || !stricmp(parv[1], "halp")) // If no args found or first arg is "help"
+	if(!stricmp(parv[1], "help") || !stricmp(parv[1], "halp")) // Or first arg is halp
 		return dumpit(sptr, muhhalp); // Return help string instead
 
 	// Need to offset parv to the left if we got a shorthand like /mshun -dick@butt

+ 1 - 1
u4/m_anti_amsg.c

@@ -123,7 +123,7 @@ static int anti_amsg_override(Cmdoverride *ovr, aClient *cptr, aClient *sptr, in
 	}
 
 	// Also duplicate messages at the exact same time
-	else if(!BadPtr(parv[2])) {
+	if(!BadPtr(parv[2])) {
 		// Some shitty ass scripts may use different colours/markup across chans, so fuck that
 		if(!(body = (char *)StripControlCodes(parv[2])))
 			return CallCmdoverride(ovr, cptr, sptr, parc, parv);

+ 4 - 6
u4/m_denyban.c

@@ -44,7 +44,7 @@ char *denyReason = NULL; // What message to display
 // Dat dere module header
 ModuleHeader MOD_HEADER(m_denyban) = {
 	"m_denyban", // Module name
-	"$Id: v1.05 2018/03/02 Gottem$", // Version
+	"$Id: v1.06 2019/01/24 Gottem$", // Version
 	"Deny specific ban masks network-wide", // Description
 	"3.2-b8-1", // Modversion, not sure wat do
 	NULL
@@ -360,7 +360,7 @@ static int denyban_modeoverride(Cmdoverride *ovr, aClient *cptr, aClient *sptr,
 				j = mc + 3; // In parv[] the first mask is found at index 3
 
 				// Finito?
-				if(BadPtr(parv[j])) {
+				if(parc <= j || BadPtr(parv[j])) {
 					breakem = 1;
 					break;
 				}
@@ -398,10 +398,8 @@ static int denyban_modeoverride(Cmdoverride *ovr, aClient *cptr, aClient *sptr,
 			case 'k': // Channel key
 			case 'L': // Channel link
 			case 'l': // Limit
-				if(!BadPtr(parv[mc + 3])) {
-					mc++; // Simply increment the mask counter so we pass over it
-					newparc++;
-				}
+				mc++; // Simply increment the mask counter so we pass over it
+				newparc++;
 				break;
 
 			// Directionals yo

+ 6 - 3
u4/m_noinvite.c

@@ -35,7 +35,7 @@ long noinvite_extumode = 0L; // Store bitwise value latur
 // Dat dere module header
 ModuleHeader MOD_HEADER(m_noinvite) = {
 	"m_noinvite", // Module name
-	"$Id: v1.02 2018/09/25 Gottem$", // Version
+	"$Id: v1.03 2019/01/24 Gottem$", // Version
 	"Adds umode +N to block invites", // Description
 	"3.2-b8-1", // Modversion, not sure wat do
 	NULL
@@ -78,8 +78,11 @@ MOD_UNLOAD(m_noinvite) {
 #if BACKPORT
 	static int noinvite_override_invite(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int parc, char *parv[]) {
 		aClient *acptr;
-		if(!IsOper(sptr) && !BadPtr(parv[1]) && (acptr = find_person(parv[1], NULL)) && (acptr->umodes & noinvite_extumode)) {
-			if(!BadPtr(parv[2]) && find_channel(parv[2], NULL)) {
+		if(BadPtr(parv[1]) || BadPtr(parv[2]))
+			return CallCmdoverride(ovr, cptr, sptr, parc, parv); // Run original function yo
+
+		if(!IsOper(sptr) && (acptr = find_person(parv[1], NULL)) && (acptr->umodes & noinvite_extumode)) {
+			if(find_channel(parv[2], NULL)) {
 				sendto_one(sptr, ":%s NOTICE %s :%s has blocked all invites", me.name, parv[2], parv[1]);
 				return 0;
 			}

+ 32 - 32
u4/m_rtkl.c

@@ -60,7 +60,7 @@ static char *rtklhelp[] = {
 // Dat dere module header
 ModuleHeader MOD_HEADER(m_rtkl) = {
 	"m_rtkl", // Module name
-	"$Id: v1.0 2017/07/24 Gottem$", // Version
+	"$Id: v1.01 2019/01/24 Gottem$", // Version
 	"Allows privileged opers to remove remote servers' local K/Z:Lines", // Description
 	"3.2-b8-1", // Modversion, not sure wat do
 	NULL
@@ -193,44 +193,44 @@ int hook_tkl_del(aClient *cptr, aClient *sptr, aTKline *tkl, int parc, char *par
 int hook_tkl_main(aClient *cptr, aClient *sptr, aTKline *tkl, int parc, char *parv[], char flag) {
 	char *p, *nick; // To get just the nick bit from the full user!ident@host mask lol
 	aClient *acptr; // Pointer to the client using that nick
-	if(sptr && !MyClient(sptr) && !BadPtr(parv[5]) && strchr("zk", *parv[2])) { // Only respond to non-local clients and _local_ K/Z:Lines ;];]
-		nick = strdup(parv[5]);
-		if(!(p = strrchr(nick, '!'))) // If for some reason the arg is malformed (expecting user!ident@host here), bail the fuck out
-			return 0;
-		*p = '\0';
-		if(!(acptr = find_person(nick, NULL))) // Validate target nick
-			return 0; // Lolnope
-
-		char buf[BUFSIZE]; // Outbut buffer lol
-		char *timeret; // Time buffer yo
+	if(sptr || MyClient(sptr) || parc < 6 || BadPtr(parv[5]) || !strchr("zk", *parv[2])) // Only respond to non-local clients and _local_ K/Z:Lines ;];]
+		return 0; // kbye
+	nick = strdup(parv[5]);
+	if(!(p = strrchr(nick, '!'))) // If for some reason the arg is malformed (expecting user!ident@host here), bail the fuck out
+		return 0;
+	*p = '\0';
+	if(!(acptr = find_person(nick, NULL))) // Validate target nick
+		return 0; // Lolnope
 
-		memset(buf, '\0', BUFSIZE); // Just in caes lol
+	char buf[BUFSIZE]; // Outbut buffer lol
+	char *timeret; // Time buffer yo
 
-		// Let's build that fucking message
-		ircsnprintf(buf, BUFSIZE, "[m_rtkl] %s", (flag == '+' ? "Added" : "Removed")); // Let's start with the "direction"
+	memset(buf, '\0', BUFSIZE); // Just in caes lol
 
-		// Check if the X:Line is permanent
-		if(tkl->expire_at == 0)
-			ircsnprintf(buf, BUFSIZE, "%s permanent", buf); // Append that shit
+	// Let's build that fucking message
+	ircsnprintf(buf, BUFSIZE, "[m_rtkl] %s", (flag == '+' ? "Added" : "Removed")); // Let's start with the "direction"
 
-		// Always mention the X:Line type and the user@host mask
-		ircsnprintf(buf, BUFSIZE, "%s (local) %c:Line for %s@%s", buf, toupper(*parv[2]), tkl->usermask, tkl->hostmask);
+	// Check if the X:Line is permanent
+	if(tkl->expire_at == 0)
+		ircsnprintf(buf, BUFSIZE, "%s permanent", buf); // Append that shit
 
-		// If deleting only...
-		if(flag == '-') {
-			timeret = asctime(gmtime((TS *)&tkl->set_at)); // ...get original "set at" time as a char * ...
-			ircsnprintf(buf, BUFSIZE, "%s set by %s at %s GMT", buf, tkl->setby, timeret); // ...as well as "setby", then append that shit
-		}
+	// Always mention the X:Line type and the user@host mask
+	ircsnprintf(buf, BUFSIZE, "%s (local) %c:Line for %s@%s", buf, toupper(*parv[2]), tkl->usermask, tkl->hostmask);
 
-		if(tkl->expire_at > 0) { // If the X:Line would've expired (deleting) or will expire at some point (adding) ...
-			timeret = asctime(gmtime((TS *)&tkl->expire_at)); // ... get that shit too as a char * ...
-			ircsnprintf(buf, BUFSIZE, "%s (to expire at %s GMT, reason: ", buf, timeret); // ...and append em w/o setby (is not necessary when adding)
-		}
-		else // Permanent X:Line, no need for expiration field
-			ircsnprintf(buf, BUFSIZE, "%s (reason: ", buf); // Open parenthesis group thingy for da raisin
+	// If deleting only...
+	if(flag == '-') {
+		timeret = asctime(gmtime((TS *)&tkl->set_at)); // ...get original "set at" time as a char * ...
+		ircsnprintf(buf, BUFSIZE, "%s set by %s at %s GMT", buf, tkl->setby, timeret); // ...as well as "setby", then append that shit
+	}
 
-		ircsnprintf(buf, BUFSIZE, "%s %s)", buf, tkl->reason); // Actual reason gets appended here lol, w/ closing parenthesis
-		sendnotice(acptr, buf); // Send that fucking abomination
+	if(tkl->expire_at > 0) { // If the X:Line would've expired (deleting) or will expire at some point (adding) ...
+		timeret = asctime(gmtime((TS *)&tkl->expire_at)); // ... get that shit too as a char * ...
+		ircsnprintf(buf, BUFSIZE, "%s (to expire at %s GMT, reason: ", buf, timeret); // ...and append em w/o setby (is not necessary when adding)
 	}
+	else // Permanent X:Line, no need for expiration field
+		ircsnprintf(buf, BUFSIZE, "%s (reason: ", buf); // Open parenthesis group thingy for da raisin
+
+	ircsnprintf(buf, BUFSIZE, "%s %s)", buf, tkl->reason); // Actual reason gets appended here lol, w/ closing parenthesis
+	sendnotice(acptr, buf); // Send that fucking abomination
 	return 0; // Can't do shit anyways =]
 }

+ 4 - 3
uncommon/m_bancheck_access.c

@@ -26,7 +26,7 @@ int showNotif = 0; // Display message in case of disallowed masks
 // Dat dere module header
 ModuleHeader MOD_HEADER(m_bancheck_access) = {
 	"m_bancheck_access", // Module name
-	"$Id: v1.11 2017/11/26 Gottem$", // Version
+	"$Id: v1.12 2019/01/24 Gottem$", // Version
 	"Prevents people who have +o or higher from getting banned, unless done by people with +a/+q or opers", // Description
 	"3.2-b8-1", // Modversion, not sure wat do
 	NULL
@@ -175,7 +175,7 @@ static int bancheck_override(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int
 				j = 3 + mc++; // In parv[] the first mask is found at index 3
 
 				// Finito?
-				if(BadPtr(parv[j])) {
+				if(parc <= j || BadPtr(parv[j])) {
 					breakem = 1;
 					break;
 				}
@@ -231,6 +231,7 @@ static int bancheck_override(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int
 			case 'L': // Channel link
 			case 'l': // Limit
 				mc++; // Simply increment the mask counter so we pass over it
+				newparc++;
 				break;
 
 			// Directionals yo
@@ -254,7 +255,7 @@ static int bancheck_override(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int
 	}
 
 	// Now checkem masks, we have to do this separately so we can reliably get the (proper) corresponding mask
-	for(i = 3, j = 3; !BadPtr(parv[i]); i++) {
+	for(i = 3, j = 3; i < parc && !BadPtr(parv[i]); i++) {
 		if(skip[i] || !strlen(parv[i]))
 			continue;
 

+ 3 - 3
uncommon/m_textshun.c

@@ -97,7 +97,7 @@ static char *muhhalp[] = {
 // Dat dere module header
 ModuleHeader MOD_HEADER(m_textshun) = {
 	"m_textshun", // Module name
-	"$Id: v1.06 2018/12/22 Gottem$", // Version
+	"$Id: v1.07 2019/01/24 Gottem$", // Version
 	"Drop messages based on nick and body", // Description
 	"3.2-b8-1", // Modversion, not sure wat do
 	NULL
@@ -461,9 +461,9 @@ CMD_FUNC(m_textshun) {
 	}
 
 	// Need at least 4 args lol
-	if(parc <= 2 || !stricmp(parv[1], "help") || !stricmp(parv[1], "halp")) {
+	if(!stricmp(parv[1], "help") || !stricmp(parv[1], "halp"))
 		return dumpit(sptr, muhhalp); // Return help string instead
-	}
+
 	del = (!stricmp(parv[1], "del") ? 1 : 0); // Are we deleting?
 	if((!del && parc < 5) || (del && parc < 4)) { // Delete doesn't require the expire and reason fields
 		sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, sptr->name, "TEXTSHUN"); // Need m0ar lol