[srvx-commits] CVS: services/src chanserv.c,1.273,1.274 messages.h,1.28,1.29 opserv.c,1.262,1.263 pr
Brought to you by:
entrope
|
From: Zoot <zo...@us...> - 2002-08-14 21:55:53
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv16364/src
Modified Files:
chanserv.c messages.h opserv.c proto-bahamut.c proto-p10.c
proto.h
Log Message:
Make sure mode changes from users are valid before sending them out; make verify_mod_chanmode() handle validating and actually applying the channel modes locally.
Index: chanserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/chanserv.c,v
retrieving revision 1.273
retrieving revision 1.274
diff -C2 -r1.273 -r1.274
*** chanserv.c 14 Aug 2002 20:05:02 -0000 1.273
--- chanserv.c 14 Aug 2002 21:55:48 -0000 1.274
***************
*** 230,234 ****
#define CSMSG_TOPIC_MISMATCH "Warning: The default topic for $b%s$b does not match the topic mask; changing it anyway."
- #define CSMSG_MODES_INVALID "$b%s$b is an invalid set of channel modes."
#define CSMSG_MODES_SET "Channel modes are now $b%s$b."
#define CSMSG_NO_MODES "$b%s$b does not have any default modes."
--- 230,233 ----
***************
*** 3849,3859 ****
changes = unsplit_string(argv + 1, argc - 1, NULL);
! if(!verify_chanmode(changes, 0))
{
! chanserv_notice(user, CSMSG_MODES_INVALID, changes);
return 0;
}
-
- mod_chanmode(channel, chanserv, changes, NULL, 0);
if(!check_user_level(user, channel, channel->channel_info->options[optEnfModes], 1, 0))
--- 3848,3856 ----
changes = unsplit_string(argv + 1, argc - 1, NULL);
! if(!verify_mod_chanmode(channel, chanserv, changes, NULL, 0, 0))
{
! chanserv_notice(user, MSG_INVALID_MODES, changes);
return 0;
}
if(!check_user_level(user, channel, channel->channel_info->options[optEnfModes], 1, 0))
Index: messages.h
===================================================================
RCS file: /cvsroot/srvx/services/src/messages.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -r1.28 -r1.29
*** messages.h 30 Jul 2002 02:15:11 -0000 1.28
--- messages.h 14 Aug 2002 21:55:49 -0000 1.29
***************
*** 54,57 ****
--- 54,58 ----
#define MSG_MODULE_UNKNOWN "No module has been registered with name $b%s$b."
+ #define MSG_INVALID_MODES "$b%s$b is an invalid set of channel modes."
#define MSG_INVALID_GLINE "Invalid G-line '%s'."
#define MSG_INVALID_DURATION "Invalid time span '%s'."
Index: opserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/opserv.c,v
retrieving revision 1.262
retrieving revision 1.263
diff -C2 -r1.262 -r1.263
*** opserv.c 14 Aug 2002 01:36:11 -0000 1.262
--- opserv.c 14 Aug 2002 21:55:49 -0000 1.263
***************
*** 1129,1138 ****
OPSERV_MIN_PARMS(2, true);
changes = unsplit_string(argv+1, argc-1, NULL);
! if (channel->modes & MODE_KEY) {
! char *mc = alloca(strlen(channel->key)+4);
! sprintf(mc, "-k %s", channel->key);
! irc_mode(opserv, channel, mc);
}
- mod_chanmode(channel, opserv, changes, NULL, 0);
irc_mode(opserv, channel, changes);
opserv_notice(user, OSMSG_MODE_SET, channel->name);
--- 1129,1139 ----
OPSERV_MIN_PARMS(2, true);
changes = unsplit_string(argv+1, argc-1, NULL);
!
! /* Pass 1 as the last argument to allow opers to fiddle with +bov
! modes. */
! if(!verify_mod_chanmode(channel, opserv, changes, NULL, 0, 1)) {
! opserv_notice(user, MSG_INVALID_MODES, changes);
! return 0;
}
irc_mode(opserv, channel, changes);
opserv_notice(user, OSMSG_MODE_SET, channel->name);
Index: proto-bahamut.c
===================================================================
RCS file: /cvsroot/srvx/services/src/proto-bahamut.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** proto-bahamut.c 14 Aug 2002 20:25:08 -0000 1.17
--- proto-bahamut.c 14 Aug 2002 21:55:49 -0000 1.18
***************
*** 1059,1068 ****
}
! int verify_chanmode(const char *modes, int member)
{
! const char *word = modes;
! int add = -1, res, limit;
!
! res = 1;
if(!modes) return 0;
--- 1059,1066 ----
}
! int verify_mod_chanmode(struct chanNode *channel, struct userNode *who, const char *modes, const char *key, int limit, int member)
{
! const char *start = modes, *word = modes;
! int add = -1;
if(!modes) return 0;
***************
*** 1081,1088 ****
case ' ':
/* Reject the mode if there's crap on the end. */
! if(*word) {
return 0;
}
! return (add == -1) ? 0 : 1;
case '+':
add = 1;
--- 1079,1086 ----
case ' ':
/* Reject the mode if there's crap on the end. */
! if(*word || (add == -1)) {
return 0;
}
! goto success;
case '+':
add = 1;
***************
*** 1123,1128 ****
return 0;
}
! limit = strtoul(word, NULL, 0);
! if(limit < 1) {
return 0;
}
--- 1121,1125 ----
return 0;
}
! if(strtoul(word, NULL, 0) < 1) {
return 0;
}
***************
*** 1148,1152 ****
#undef advance_word
! return 0;
}
--- 1145,1150 ----
#undef advance_word
! success:
! return mod_chanmode(channel, who, start, key, limit);
}
Index: proto-p10.c
===================================================================
RCS file: /cvsroot/srvx/services/src/proto-p10.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -r1.25 -r1.26
*** proto-p10.c 14 Aug 2002 20:25:08 -0000 1.25
--- proto-p10.c 14 Aug 2002 21:55:49 -0000 1.26
***************
*** 1827,1836 ****
}
! int verify_chanmode(const char *modes, int member)
{
! const char *word = modes;
! int add = -1, res, limit;
!
! res = 1;
if(!modes) return 0;
--- 1827,1834 ----
}
! int verify_mod_chanmode(struct chanNode *channel, struct userNode *who, const char *modes, const char *key, int limit, int member)
{
! const char *start = modes, *word = modes;
! int add = -1;
if(!modes) return 0;
***************
*** 1849,1856 ****
case ' ':
/* Reject the mode if there's crap on the end. */
! if(*word) {
return 0;
}
! return (add == -1) ? 0 : 1;
case '+':
add = 1;
--- 1847,1854 ----
case ' ':
/* Reject the mode if there's crap on the end. */
! if(*word || (add == -1)) {
return 0;
}
! goto success;
case '+':
add = 1;
***************
*** 1892,1897 ****
return 0;
}
! limit = strtoul(word, NULL, 0);
! if(limit < 1) {
return 0;
}
--- 1890,1894 ----
return 0;
}
! if(strtoul(word, NULL, 0) < 1) {
return 0;
}
***************
*** 1917,1921 ****
#undef advance_word
! return 0;
}
--- 1914,1919 ----
#undef advance_word
! success:
! return mod_chanmode(channel, who, start, key, limit);
}
***************
*** 1928,1932 ****
chan_mode_t old;
! if(!word || !*word) {
return 0;
}
--- 1926,1930 ----
chan_mode_t old;
! if(!modes || !*modes) {
return 0;
}
Index: proto.h
===================================================================
RCS file: /cvsroot/srvx/services/src/proto.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -C2 -r1.63 -r1.64
*** proto.h 14 Aug 2002 20:25:08 -0000 1.63
--- proto.h 14 Aug 2002 21:55:49 -0000 1.64
***************
*** 178,182 ****
/* Channel modes */
int irc_make_chanmode(struct chanNode *chan, char *out);
! int verify_chanmode(const char *modes, int member);
int mod_chanmode(struct chanNode *channel, struct userNode *who, const char *modes, const char *key, int limit);
/* (most protocols will want to make an AddUser helper function) */
--- 178,182 ----
/* Channel modes */
int irc_make_chanmode(struct chanNode *chan, char *out);
! int verify_mod_chanmode(struct chanNode *channel, struct userNode *who, const char *modes, const char *key, int limit, int member);
int mod_chanmode(struct chanNode *channel, struct userNode *who, const char *modes, const char *key, int limit);
/* (most protocols will want to make an AddUser helper function) */
|