From: Christian Heller Date: Mon, 31 Mar 2014 02:24:10 +0000 (+0200) Subject: Make textfile_width() check for too large lines. X-Git-Tag: tce~788 X-Git-Url: https://plomlompom.com/repos/te"st.html?a=commitdiff_plain;h=1008f26c7c6855f59222bcbe2cd1505ba8a6f28f;p=plomrogue Make textfile_width() check for too large lines. --- diff --git a/TODO b/TODO index 42c0e9a..16d126b 100644 --- a/TODO +++ b/TODO @@ -9,8 +9,6 @@ BOTH SERVER/CLIENT: - be more strict and humble when allocating memory from the stack -- in textfield_width(), handle too large lines somehow - - may err_line store the processed line internally as it does the line count SERVER: diff --git a/src/common/readwrite.c b/src/common/readwrite.c index a0ab3f7..3dcd2a2 100644 --- a/src/common/readwrite.c +++ b/src/common/readwrite.c @@ -2,7 +2,7 @@ #include "readwrite.h" #include /* size_t */ -#include /* uint8_t, uint16_t, uint32_t */ +#include /* uint8_t, uint16_t, uint32_t, UINT32_MAX */ #include /* FILE, fseek(), sprintf(), fgets(), fgetc(), ferror(), * fputc(), fwrite(), fclose(), fopen() */ @@ -108,6 +108,7 @@ extern uint32_t textfile_width(FILE * file) { break; } + exit_trouble(UINT32_MAX == c_count, f_name, "too large text file line"); c_count++; if ('\n' == c) {