diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-11-21 18:23:08 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-11-21 18:23:08 +0000 |
commit | b60826b40d84bd3807fe8fa18bce8117fc5051e3 (patch) | |
tree | a3ff3c9696c9b021d1d6c2230815e61904e70565 /src/map/intif.c | |
parent | a657a7f44335502eb140c269842f7dccb861e647 (diff) | |
download | hercules-b60826b40d84bd3807fe8fa18bce8117fc5051e3.tar.gz hercules-b60826b40d84bd3807fe8fa18bce8117fc5051e3.tar.bz2 hercules-b60826b40d84bd3807fe8fa18bce8117fc5051e3.tar.xz hercules-b60826b40d84bd3807fe8fa18bce8117fc5051e3.zip |
- Moved ignoreAll to state.ignoreAll so it saves some space.
- Cleaned up clif_parse_Wis to prevent crashes from forged packets (using a strlen() on a string where you don't know if it's null-terminated is a NO-NO)
- Cleaned up the implementation of the ignore list so it's more efficient.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9282 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/intif.c')
-rw-r--r-- | src/map/intif.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/map/intif.c b/src/map/intif.c index bab76b40b..025d76c9b 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -845,33 +845,33 @@ int intif_parse_WisMessage(int fd) { // rewritten by [Yor] int id, i;
RFIFOHEAD(fd);
id=RFIFOL(fd,4);
- i=0; //,j=0;
-// if(battle_config.etc_log)
-// printf("intif_parse_wismessage: %d %s %s %s\n",id,RFIFOP(fd,6),RFIFOP(fd,30),RFIFOP(fd,54) );
memcpy(name, RFIFOP(fd,32), NAME_LENGTH);
name[NAME_LENGTH-1] = '\0'; //In case name arrived without it's terminator. [Skotlex]
- sd=(struct map_session_data *) map_nick2sd(name); // 送信先を探す
- if(sd!=NULL && strcmp(sd->status.name, name) == 0){
- if(sd->ignoreAll == 1)
- intif_wis_replay(RFIFOL(fd,4), 2); // 受信拒否
- else {
- wisp_source = (char *) RFIFOP(fd,8); // speed up [Yor]
- for(i=0;i<MAX_IGNORE_LIST;i++){ //拒否リストに名前があるかどうか判定してあれば拒否
- if(strcmp(sd->ignore[i].name, wisp_source)==0){
- break;
- }
- }
- if(i==MAX_IGNORE_LIST) // run out of list, so we are not ignored
- {
- clif_wis_message(sd->fd, wisp_source, (char*)RFIFOP(fd,56),RFIFOW(fd,2)-56);
- intif_wis_replay(id,0); // 送信成功
- }
- else
- intif_wis_replay(id, 2); // 受信拒否
- }
- }else
- intif_wis_replay(id,1); // そんな人いません
+ sd = map_nick2sd(name);
+ if(sd == NULL || strcmp(sd->status.name, name) != 0)
+ { //Not found
+ intif_wis_replay(id,1);
+ return 0;
+ }
+ if(sd->state.ignoreAll) {
+ intif_wis_replay(id, 2);
+ return 0;
+ }
+ wisp_source = (char *) RFIFOP(fd,8); // speed up [Yor]
+ for(i=0; i < MAX_IGNORE_LIST &&
+ sd->ignore[i].name[0] != '\0' &&
+ strcmp(sd->ignore[i].name, wisp_source) != 0
+ ; i++);
+
+ if (i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0')
+ { //Ignored
+ intif_wis_replay(id, 2);
+ return 0;
+ }
+ //Success to send whisper.
+ clif_wis_message(sd->fd, wisp_source, (char*)RFIFOP(fd,56),RFIFOW(fd,2)-56);
+ intif_wis_replay(id,0); // 送信成功
return 0;
}
|