diff options
author | remoitnane <remoit(DOT)nane(AT)gmail(DOT)com> | 2010-09-05 18:41:32 -0700 |
---|---|---|
committer | remoitnane <remoit(DOT)nane(AT)gmail(DOT)com> | 2010-09-05 18:41:32 -0700 |
commit | e2f46583ef4b9fb062b8cf85b2337a893ded5641 (patch) | |
tree | b3a9b978296a487ac41b6a2529f5b3d43cd202a9 /src/map/clif.c | |
parent | 729fa55b9d7b7f29c6a152ad6846eac1bc43cdee (diff) | |
download | tmwa-e2f46583ef4b9fb062b8cf85b2337a893ded5641.tar.gz tmwa-e2f46583ef4b9fb062b8cf85b2337a893ded5641.tar.bz2 tmwa-e2f46583ef4b9fb062b8cf85b2337a893ded5641.tar.xz tmwa-e2f46583ef4b9fb062b8cf85b2337a893ded5641.zip |
Clean up NPC string input and minor formatting
Diffstat (limited to 'src/map/clif.c')
-rw-r--r-- | src/map/clif.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 93ff805..81a57f1 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8178,7 +8178,9 @@ void clif_parse_NpcAmountInput (int fd, struct map_session_data *sd) } /*========================================== + * Process string-based input for an NPC. * + * (S 01d5 <len>.w <npc_ID>.l <message>.?B) *------------------------------------------ */ void clif_parse_NpcStringInput (int fd, struct map_session_data *sd) @@ -8186,16 +8188,25 @@ void clif_parse_NpcStringInput (int fd, struct map_session_data *sd) int len; nullpo_retv (sd); - len = RFIFOW (fd, 2) - 7; + len = RFIFOW (fd, 2) - 8; - if (len >= sizeof (sd->npc_str)-1) + /* + * If we check for equal to 0, too, we'll freeze clients that send (or + * claim to have sent) an "empty" message. + */ + if (len < 0) + return; + + if (len >= sizeof (sd->npc_str) - 1) { - printf ("clif: input string too long !\n"); - memcpy (sd->npc_str, RFIFOP (fd, 8), sizeof (sd->npc_str)); + printf ("clif_parse_NpcStringInput(): Input string too long!\n"); + len = sizeof (sd->npc_str) - 1; } - else + + if (len > 0) strncpy (sd->npc_str, RFIFOP (fd, 8), len); - sd->npc_str[sizeof (sd->npc_str) - 1] = 0; + sd->npc_str[len] = '\0'; + map_scriptcont (sd, RFIFOL (fd, 4)); } @@ -8756,7 +8767,6 @@ void clif_parse_GuildMessage (int fd, struct map_session_data *sd) return; } - guild_send_message (sd, message, RFIFOW (fd, 2) - 4); free (buf); } |