瀏覽代碼

Fixed motd parsing

Fixed #2220

Thanks to @anacondaqq
Lemongrass3110 8 年之前
父節點
當前提交
9827bf6153
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      src/map/pc.c

+ 3 - 2
src/map/pc.c

@@ -11322,10 +11322,10 @@ int pc_read_motd(void)
 	if( ( fp = fopen(motd_txt, "r") ) != NULL )
 	{
 		unsigned int entries = 0;
+		char buf[CHAT_SIZE_MAX];
 
-		while( entries < MOTD_LINE_SIZE && fgets(motd_text[entries], sizeof(motd_text[entries]), fp) )
+		while( entries < MOTD_LINE_SIZE && fgets(buf, CHAT_SIZE_MAX, fp) )
 		{
-			char* buf = motd_text[entries];
 			unsigned int lines = 0;
 			size_t len;
 			lines++;
@@ -11344,6 +11344,7 @@ int pc_read_motd(void)
 				buf[0] = ' ';
 				buf[1] = 0;
 			}
+			safestrncpy(motd_text[entries], buf, CHAT_SIZE_MAX);
 			entries++;
 		}
 		fclose(fp);