commit - 696ca2e001859285c853f0e8c5986ef5db36d400
commit + cb3041d16021d46c9d5d0ec1d848ce91702212b4
blob - a7a5ea108c76e3650132cf25ffa46adc24ea4056
blob + 06592cc7ce5929a7df8bf32faa36911dd43489e1
--- FICS/comproc.c
+++ FICS/comproc.c
result converted to larger type.
Markus Uhlin 25/07/24 Fixed use of potentially
dangerous functions.
+ Markus Uhlin 25/07/29 Usage of 'int64_t'.
*/
#include "stdinclude.h"
#include <err.h>
#include <errno.h>
+#include <inttypes.h>
+#include <stdint.h>
#include "board.h"
#include "command.h"
PUBLIC void
rscan_news2(FILE *fp, int p, int num)
{
+ char count[10] = { '\0' };
+ char junk[MAX_LINE_SIZE] = { '\0' };
char *junkp;
- char count[10] = { '\0' };
- char junk[MAX_LINE_SIZE] = { '\0' };
- long int lval;
+ int64_t lval;
time_t crtime;
if (num == 0)
return;
if (fgets(junk, sizeof junk, fp) == NULL || feof(fp) ||
- sscanf(junk, "%ld %9s", &lval, count) != 2)
+ sscanf(junk, "%" SCNd64 " " "%9s", &lval, count) != 2)
return;
rscan_news2(fp, p, num - 1);
com_news(int p, param_list param)
{
FILE *fp = NULL;
- char *junkp = NULL;
char count[10] = { '\0' };
char filename[MAX_FILENAME_SIZE] = { '\0' };
char junk[MAX_LINE_SIZE] = { '\0' };
+ char *junkp = NULL;
int found = 0;
- long int lval = 0;
+ int64_t lval = 0;
time_t crtime = 0;
snprintf(filename, sizeof filename, "%s/newnews.index", news_dir);
return COM_OK;
}
-#define SCAN_JUNK "%ld %9s"
+#define SCAN_JUNK ("%" SCNd64 " " "%9s")
_Static_assert(9 < ARRAY_SIZE(count), "'count' too small");
if (param[0].type == 0) {
char ipstr[20] = { '\0' };
char loginName[MAX_LOGIN_NAME + 1] = { '\0' };
int registered = 0;
- long int lval = 0;
+ int64_t lval = 0;
time_t tval = 0;
uint16_t inout = 0;
_Static_assert(19 < ARRAY_SIZE(ipstr), "'ipstr' too small");
_Static_assert(19 < ARRAY_SIZE(loginName), "'loginName' too small");
+#define SCAN_FMT ("%" SCNu16 " %19s " "%" SCNd64 " " "%d %19s\n")
while (!feof(fp)) {
- if (fscanf(fp, "%hu %19s %ld %d %19s\n", &inout, loginName,
- &lval, ®istered, ipstr) != 5) {
+ if (fscanf(fp, SCAN_FMT, &inout, loginName, &lval, ®istered,
+ ipstr) != 5) {
fprintf(stderr, "FICS: Error in login info format. "
"%s\n", fname);
fclose(fp);