aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md3
-rw-r--r--FICS/comproc.c20
-rw-r--r--FICS/gamedb.c4
-rw-r--r--FICS/makerank.c28
-rw-r--r--FICS/ratings.c6
-rw-r--r--README.md14
6 files changed, 64 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 279893b..2e330ac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,8 @@ All notable changes to this fork of FICS version 1.6.2 will be
documented in this file.
## [Unreleased] ##
+- Changed the addplayer program to output a restart notice if an admin
+ account is created.
- Changed the program to avoid calculating the same string multiple
times. Multiple occurrences, found by PVS-Studio.
- Fixed `-Wshadow` warnings. Multiple occurrences.
@@ -15,6 +17,7 @@ documented in this file.
- Fixed overflowed array index read/write. Multiple occurrences.
- Fixed overflowed return value in `player_search()`.
- Fixed possible buffer overflow in `FindHistory2()`.
+- Fixed truncated stdio return value in `ReadGameState()`.
- Fixed unchecked function return values. Multiple occurrences.
- Fixed uninitialized variables.
- Fixed untrusted array indices.
diff --git a/FICS/comproc.c b/FICS/comproc.c
index 4f33d4c..31f6064 100644
--- a/FICS/comproc.c
+++ b/FICS/comproc.c
@@ -41,6 +41,8 @@
value 'rat' in who_terse().
Markus Uhlin 25/03/16 Fixed use of 32-bit 'time_t'.
Markus Uhlin 25/03/16 Fixed untrusted array index.
+ Markus Uhlin 25/03/25 com_unalias: fixed overflowed
+ array index read/write.
*/
#include "stdinclude.h"
@@ -1639,14 +1641,32 @@ com_unalias(int p, param_list param)
pprintf(p, "You have no alias named '%s'.\n",
param[0].val.word);
} else {
+ bool removed = false;
+ const int sz = (int) ARRAY_SIZE(parray[0].alias_list);
+
rfree(parray[p].alias_list[al].comm_name);
rfree(parray[p].alias_list[al].alias);
+ parray[p].alias_list[al].comm_name = NULL;
+ parray[p].alias_list[al].alias = NULL;
+
for (int i = al; i < parray[p].numAlias; i++) {
+ if (i >= sz || i + 1 >= sz) {
+ warnx("%s: overflowed array index read/write",
+ __func__);
+ break;
+ }
+
parray[p].alias_list[i].comm_name =
parray[p].alias_list[i + 1].comm_name;
parray[p].alias_list[i].alias =
parray[p].alias_list[i + 1].alias;
+ removed = true;
+ }
+
+ if (!removed) {
+ pprintf(p, "Remove error.\n");
+ return COM_FAILED;
}
parray[p].numAlias--;
diff --git a/FICS/gamedb.c b/FICS/gamedb.c
index 6845c1d..a34fd89 100644
--- a/FICS/gamedb.c
+++ b/FICS/gamedb.c
@@ -37,6 +37,8 @@
Markus Uhlin 24/12/02 Fixed bugs and ignored function
return values.
Markus Uhlin 25/03/18 Fixed unchecked return values
+ Markus Uhlin 25/03/25 ReadGameState: fixed truncated
+ stdio return value.
*/
#include "stdinclude.h"
@@ -975,8 +977,8 @@ WriteGameState(FILE *fp, game_state_t *gs)
PRIVATE int
ReadGameState(FILE *fp, game_state_t *gs, int version)
{
- char pieceChar;
int i, j;
+ int pieceChar;
int wkmoved, wqrmoved, wkrmoved, bkmoved, bqrmoved, bkrmoved;
if (version == 0) {
diff --git a/FICS/makerank.c b/FICS/makerank.c
index bdc4d3b..4458f31 100644
--- a/FICS/makerank.c
+++ b/FICS/makerank.c
@@ -110,21 +110,33 @@ GetPlayerInfo(char *fileName, ENTRY *e)
"strlcpy() truncated\n", __func__);
}
} else if (!strcmp(field, "S_NUM:")) {
- sscanf(line, "%*s %d", &(e->r[0].num));
+ if (sscanf(line, "%*s %d", &(e->r[0].num)) != 1)
+ warnx("%s: S_NUM error", __func__);
} else if (!strcmp(field, "B_NUM:")) {
- sscanf(line, "%*s %d", &(e->r[1].num));
+ if (sscanf(line, "%*s %d", &(e->r[1].num)) != 1)
+ warnx("%s: B_NUM error", __func__);
} else if (!strcmp(field, "W_NUM:")) {
- sscanf(line, "%*s %d", &(e->r[2].num));
+ if (sscanf(line, "%*s %d", &(e->r[2].num)) != 1)
+ warnx("%s: W_NUM error", __func__);
} else if (!strcmp(field, "L_NUM:")) {
- sscanf(line, "%*s %d", &(e->r[3].num));
+ if (sscanf(line, "%*s %d", &(e->r[3].num)) != 1)
+ warnx("%s: L_NUM error", __func__);
} else if (!strcmp(field, "S_RATING:")) {
- sscanf(line, "%*s %d", &(e->r[0].rating));
+ if (sscanf(line, "%*s %d",
+ &(e->r[0].rating)) != 1)
+ warnx("%s: S_RATING error", __func__);
} else if (!strcmp(field, "B_RATING:")) {
- sscanf(line, "%*s %d", &(e->r[1].rating));
+ if (sscanf(line, "%*s %d",
+ &(e->r[1].rating)) != 1)
+ warnx("%s: B_RATING error", __func__);
} else if (!strcmp(field, "W_RATING:")) {
- sscanf(line, "%*s %d", &(e->r[2].rating));
+ if (sscanf(line, "%*s %d",
+ &(e->r[2].rating)) != 1)
+ warnx("%s: W_RATING error", __func__);
} else if (!strcmp(field, "L_RATING:")) {
- sscanf(line, "%*s %d", &(e->r[3].rating));
+ if (sscanf(line, "%*s %d",
+ &(e->r[3].rating)) != 1)
+ warnx("%s: L_RATING error", __func__);
} else if (!strcmp(field, "Network:")) {
done = 1;
}
diff --git a/FICS/ratings.c b/FICS/ratings.c
index b860260..3a7cdd0 100644
--- a/FICS/ratings.c
+++ b/FICS/ratings.c
@@ -39,6 +39,7 @@
#include <err.h>
#include <errno.h>
+#include <stdint.h>
#include "command.h"
#include "comproc.h"
@@ -755,7 +756,7 @@ GE(int r, int rr, double ss, double *fss)
}
PRIVATE double
-current_sterr(double s, int t)
+current_sterr(double s, int64_t t)
{
if (t < 0)
t = 0; // this shouldn't happen
@@ -776,9 +777,10 @@ rating_sterr_delta(int p1, int p2, int type, time_t gtime, int result,
double E, fs2, denominator, GK, w; // Parts of fancy formulas
double delta, sigma; // Results to return
double s1, s2;
- int t1, r1, t2, r2; // Initial sterrs and ratings
+ int r1, r2; // Initial sterrs and ratings
statistics *p1_stats;
statistics *p2_stats;
+ time_t t1, t2;
if (type == TYPE_BLITZ) {
p1_stats = &parray[p1].b_stats;
diff --git a/README.md b/README.md
index 4a92f79..ad34c47 100644
--- a/README.md
+++ b/README.md
@@ -37,6 +37,16 @@ repository:
$ git clone https://github.com/uhlin/fics.git
$ cd fics
+### Checkout ###
+
+If you want you can checkout a specific version. For example:
+
+ $ git checkout 1.4.4
+
+To see all tags, type:
+
+ $ git tag
+
Edit `FICS/config.h` with a text editor and save the file.
$ emacs FICS/config.h
@@ -53,6 +63,10 @@ running `make install`.
Done!
+**NOTE**:
+Running `make install` multiple times is totally fine and does no harm
+when a new version of FICS is available.
+
### Make variables ###
If you want you can customize the `FICS_HOME` and `PREFIX` make