diff --git a/src/char/int_mail.cpp b/src/char/int_mail.cpp index 98b43b6000..7c97f66168 100644 --- a/src/char/int_mail.cpp +++ b/src/char/int_mail.cpp @@ -487,7 +487,7 @@ void mapif_Mail_return(int fd, uint32 char_id, int mail_id) // If it was not sent by the server, since we do not want to return mails to the server else if( msg.send_id != 0 ) { - char temp_[MAIL_TITLE_LENGTH]; + char temp_[MAIL_TITLE_LENGTH + 3]; // swap sender and receiver SWAP(msg.send_id, msg.dest_id); @@ -496,8 +496,8 @@ void mapif_Mail_return(int fd, uint32 char_id, int mail_id) safestrncpy(msg.dest_name, temp_, NAME_LENGTH); // set reply message title - snprintf(temp_, MAIL_TITLE_LENGTH, "RE:%s", msg.title); - safestrncpy(msg.title, temp_, MAIL_TITLE_LENGTH); + snprintf(temp_, sizeof(temp_), "RE:%s", msg.title); + safestrncpy(msg.title, temp_, sizeof(temp_)); msg.status = MAIL_NEW; msg.type = MAIL_INBOX_RETURNED; diff --git a/src/common/grfio.cpp b/src/common/grfio.cpp index 6a9e91d488..4951325fe7 100644 --- a/src/common/grfio.cpp +++ b/src/common/grfio.cpp @@ -632,8 +632,8 @@ static int grfio_entryread(const char* grfname, int gentry) static bool grfio_parse_restable_row(const char* row) { char w1[256], w2[256]; - char src[256], dst[256]; - char local[256]; + char src[512], dst[512]; + char local[512]; FILELIST* entry; if( sscanf(row, "%255[^#\r\n]#%255[^#\r\n]#", w1, w2) != 2 ) diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 8ba73e9972..20cfac8aab 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -216,7 +216,7 @@ void findfile(const char *p, const char *pat, void (func)(const char*)) DIR* dir; // pointer to the scanned directory. struct dirent* entry; // pointer to one directory entry. struct stat dir_stat; // used by stat(). - char tmppath[MAX_DIR_PATH+1]; + char tmppath[MAX_DIR_PATH * 2]; char path[MAX_DIR_PATH+1]= "."; const char *pattern = (pat==NULL)? "" : pat; if(p!=NULL) strcpy(path,p); diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 314c6bbd26..7bda755b6c 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -6609,7 +6609,7 @@ ACMD_FUNC(cleanarea) *------------------------------------------*/ ACMD_FUNC(npctalk) { - char name[NPC_NAME_LENGTH],mes[100],temp[100]; + char name[NPC_NAME_LENGTH],mes[100],temp[CHAT_SIZE_MAX]; struct npc_data *nd; bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1; unsigned long color=0; @@ -6646,7 +6646,7 @@ ACMD_FUNC(npctalk) ACMD_FUNC(pettalk) { - char mes[100],temp[100]; + char mes[100],temp[CHAT_SIZE_MAX]; struct pet_data *pd; nullpo_retr(-1, sd); @@ -7537,7 +7537,7 @@ ACMD_FUNC(homhungry) *------------------------------------------*/ ACMD_FUNC(homtalk) { - char mes[100],temp[100]; + char mes[100],temp[CHAT_SIZE_MAX]; nullpo_retr(-1, sd); @@ -8128,7 +8128,7 @@ ACMD_FUNC(fakename) * Ragnarok Resources *------------------------------------------*/ ACMD_FUNC(mapflag) { - char flag_name[CHAT_SIZE_MAX]; + char flag_name[50]; short flag = 0, i, j; std::string buf; @@ -8136,7 +8136,7 @@ ACMD_FUNC(mapflag) { memset(flag_name, '\0', sizeof(flag_name)); - if (!message || !*message || (sscanf(message, "%99s %6hd", flag_name, &flag) < 1)) { + if (!message || !*message || (sscanf(message, "%49s %6hd", flag_name, &flag) < 1)) { clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map: clif_displaymessage(sd->fd,"----------------------------------"); for( i = MF_MIN; i < MF_MAX; i++ ){ @@ -10424,7 +10424,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message char output[CHAT_SIZE_MAX]; //Reconstructed message - char atcmd_msg[CHAT_SIZE_MAX]; + char atcmd_msg[CHAT_SIZE_MAX * 2]; TBL_PC * ssd = NULL; //sd for target AtCommandInfo * info; diff --git a/src/map/mob.cpp b/src/map/mob.cpp index ee5bb7dcac..968baba764 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -3739,13 +3739,14 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) struct mob_chat *mc = mob_chat(ms[i].msg_id); if (mc) { - char temp[CHAT_SIZE_MAX]; - char name[NAME_LENGTH]; + std::string name = md->name, output; + std::size_t unique = name.find("#"); - snprintf(name, sizeof name,"%s", md->name); - strtok(name, "#"); // discard extra name identifier if present [Daegaladh] - snprintf(temp, sizeof temp,"%s : %s", name, mc->msg); - clif_messagecolor(&md->bl, mc->color, temp, true, AREA_CHAT_WOC); + if (unique != std::string::npos) + name = name.substr(0, unique); // discard extra name identifier if present [Daegaladh] + output = name + " : " + mc->msg; + + clif_messagecolor(&md->bl, mc->color, output.c_str(), true, AREA_CHAT_WOC); } } if(!(battle_config.mob_ai&0x200)) { //pass on delay to same skill. @@ -4469,7 +4470,7 @@ static bool mob_parse_row_chatdb(char* fields[], int columns, int current) } if(len>(CHAT_SIZE_MAX-1)){ - ShowError("mob_chat: readdb: Message too long! Line %d, id: %d\n", current, msg_id); + ShowError("mob_parse_row_chatdb: Message too long! Line %d, id: %d\n", current, msg_id); return false; } else if( !len ){ diff --git a/src/map/npc.cpp b/src/map/npc.cpp index 33393da3bc..d8fab977e7 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -3350,7 +3350,7 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { clif_spawn(&wnd->bl); strdb_put(npcname_db, wnd->exname, wnd); } else { - static char w1[50], w2[50], w3[50], w4[50]; + static char w1[128], w2[128], w3[128], w4[128]; const char* stat_buf = "- call from instancing subsystem -\n"; snprintf(w1, sizeof(w1), "%s,%d,%d,%d", mapdata->name, snd->bl.x, snd->bl.y, snd->ud.dir); diff --git a/src/map/npc_chat.cpp b/src/map/npc_chat.cpp index 5977b55770..2ee049c18d 100644 --- a/src/map/npc_chat.cpp +++ b/src/map/npc_chat.cpp @@ -372,7 +372,7 @@ int npc_chat_sub(struct block_list* bl, va_list ap) // save out the matched strings for (i = 0; i < r; i++) { - char var[6], val[255]; + char var[255], val[255]; snprintf(var, sizeof(var), "$@p%i$", i); pcre_copy_substring(msg, offsets, r, i, val, sizeof(val)); set_var(sd, var, val);