summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/grfio.c22
-rw-r--r--src/ladmin/ladmin.c3
-rw-r--r--src/map/atcommand.c2
-rw-r--r--src/map/battle.c6
-rw-r--r--src/map/npc.c6
5 files changed, 26 insertions, 13 deletions
diff --git a/src/common/grfio.c b/src/common/grfio.c
index 4795d5b..b460dc6 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -618,7 +618,8 @@ void *grfio_reads (char *fname, int *size)
printf ("file read memory allocate error : declen\n");
goto errret;
}
- fread (buf2, 1, lentry.declen, in);
+ if (!fread (buf2, 1, lentry.declen, in))
+ goto errret;
fclose_ (in);
in = NULL;
strncpy (lentry.fn, fname, sizeof (lentry.fn) - 1);
@@ -658,7 +659,8 @@ void *grfio_reads (char *fname, int *size)
return NULL;
}
fseek (in, entry->srcpos, 0);
- fread (buf, 1, entry->srclen_aligned, in);
+ if (!fread (buf, 1, entry->srclen_aligned, in))
+ goto errret;
fclose_ (in);
buf2 = calloc (entry->declen + 1024, 1);
if (buf2 == NULL)
@@ -751,7 +753,9 @@ static int grfio_entryread (char *gfname, int gentry)
fseek (fp, 0, 2); // SEEK_END
grf_size = ftell (fp);
fseek (fp, 0, 0); // SEEK_SET
- fread (grf_header, 1, 0x2e, fp);
+ if (!fread (grf_header, 1, 0x2e, fp))
+ return 2;
+
if (strcmp (grf_header, "Master of Magic")
|| fseek (fp, getlong (grf_header + 0x1e), 1))
{ // SEEK_CUR
@@ -772,7 +776,8 @@ static int grfio_entryread (char *gfname, int gentry)
printf ("out of memory : grf_filelist\n");
return 3; // 3:memory alloc error
}
- fread (grf_filelist, 1, list_size, fp);
+ if (!fread (grf_filelist, 1, list_size, fp))
+ return 2;
fclose_ (fp);
entrys =
@@ -852,7 +857,9 @@ static int grfio_entryread (char *gfname, int gentry)
unsigned char *rBuf;
uLongf rSize, eSize;
- fread (eheader, 1, 8, fp);
+ if (!fread (eheader, 1, 8, fp))
+ return 4;
+
rSize = getlong (eheader); // Read Size
eSize = getlong (eheader + 4); // Extend Size
@@ -878,7 +885,10 @@ static int grfio_entryread (char *gfname, int gentry)
printf ("out of memory : grf extract entry table buffer\n");
return 3;
}
- fread (rBuf, 1, rSize, fp);
+
+ if (!fread (rBuf, 1, rSize, fp))
+ return 4;
+
fclose_ (fp);
decode_zip (grf_filelist, &eSize, rBuf, rSize); // Decode function
list_size = eSize;
diff --git a/src/ladmin/ladmin.c b/src/ladmin/ladmin.c
index 9ea2b28..5ef9b6c 100644
--- a/src/ladmin/ladmin.c
+++ b/src/ladmin/ladmin.c
@@ -4439,7 +4439,8 @@ int prompt ()
// get command and parameter
memset (buf, '\0', sizeof (buf));
fflush (stdin);
- fgets (buf, 1023, stdin);
+ if (!fgets (buf, 1023, stdin))
+ exit (0);
buf[1023] = '\0';
Iprintf ("\033[0m");
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index d3ea644..062e898 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -3228,7 +3228,7 @@ int atcommand_produce (const int fd, struct map_session_data *sd,
if (item_id != 0 && itemdb_exists (item_id))
sprintf (output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
else
- sprintf (output, msg_table[170]); // This item is not an equipment.
+ sprintf (output, "%s", msg_table[170]); // This item is not an equipment.
clif_displaymessage (fd, output);
return -1;
}
diff --git a/src/map/battle.c b/src/map/battle.c
index 1cee690..4ec942f 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -1671,7 +1671,7 @@ int battle_calc_damage (struct block_list *src, struct block_list *bl,
{ // ボルケーノ
if (flag & BF_SKILL && skill_get_pl (skill_num) == 3)
damage += damage * sc_data[SC_VOLCANO].val4 / 100;
- else if (!flag & BF_SKILL && battle_get_attack_element (bl) == 3)
+ else if (!(flag & BF_SKILL) && (battle_get_attack_element (bl) == 3))
damage += damage * sc_data[SC_VOLCANO].val4 / 100;
}
@@ -1679,7 +1679,7 @@ int battle_calc_damage (struct block_list *src, struct block_list *bl,
{ // バイオレントゲイル
if (flag & BF_SKILL && skill_get_pl (skill_num) == 4)
damage += damage * sc_data[SC_VIOLENTGALE].val4 / 100;
- else if (!flag & BF_SKILL && battle_get_attack_element (bl) == 4)
+ else if (!(flag & BF_SKILL) && (battle_get_attack_element (bl) == 4))
damage += damage * sc_data[SC_VIOLENTGALE].val4 / 100;
}
@@ -1687,7 +1687,7 @@ int battle_calc_damage (struct block_list *src, struct block_list *bl,
{ // デリュージ
if (flag & BF_SKILL && skill_get_pl (skill_num) == 1)
damage += damage * sc_data[SC_DELUGE].val4 / 100;
- else if (!flag & BF_SKILL && battle_get_attack_element (bl) == 1)
+ else if (!(flag & BF_SKILL) && (battle_get_attack_element (bl) == 1))
damage += damage * sc_data[SC_DELUGE].val4 / 100;
}
diff --git a/src/map/npc.c b/src/map/npc.c
index edbf548..ab0e7ff 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1543,7 +1543,8 @@ static int npc_parse_script (char *w1, char *w2, char *w3, char *w4,
for (i = strlen (srcbuf) - 1; i >= 0 && isspace (srcbuf[i]); i--);
if (i >= 0 && srcbuf[i] == '}')
break;
- fgets (line, 1020, fp);
+ if (!fgets (line, 1020, fp))
+ break;
(*lines)++;
if (feof (fp))
break;
@@ -1827,7 +1828,8 @@ static int npc_parse_function (char *w1, char *w2, char *w3, char *w4,
for (i = strlen (srcbuf) - 1; i >= 0 && isspace (srcbuf[i]); i--);
if (i >= 0 && srcbuf[i] == '}')
break;
- fgets (line, 1020, fp);
+ if (!fgets (line, 1020, fp))
+ break;
(*lines)++;
if (feof (fp))
break;