aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES6
-rw-r--r--WWW/Library/Implementation/SGML.c12
-rw-r--r--src/GridText.c35
-rw-r--r--src/HTML.c8
-rw-r--r--src/LYCharUtils.c9
-rw-r--r--src/LYStrings.c14
-rw-r--r--src/LYUtils.c4
-rw-r--r--src/TRSTable.c10
8 files changed, 63 insertions, 35 deletions
diff --git a/CHANGES b/CHANGES
index 33a49249..3f595f0a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,9 +1,11 @@
--- $LynxId: CHANGES,v 1.1097 2021/08/27 08:22:42 tom Exp $
+-- $LynxId: CHANGES,v 1.1098 2021/10/24 17:46:32 tom Exp $
===============================================================================
Changes since Lynx 2.8 release
===============================================================================
-2021-08-27 (2.9.0dev.10)
+2021-10-24 (2.9.0dev.10)
+* several fixes for problems found using asan2 with fuzzer-generated data
+ (report/testcases by Kuang-che Wu) -TD
* re-signed copyright/copying files -TD
* update fr.po, id.po, nl.po, sv.po from
http://translationproject.org/latest/lynx
diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c
index 7e04a6cc..d120644b 100644
--- a/WWW/Library/Implementation/SGML.c
+++ b/WWW/Library/Implementation/SGML.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: SGML.c,v 1.177 2021/07/23 20:36:47 tom Exp $
+ * $LynxId: SGML.c,v 1.182 2021/10/24 22:18:29 tom Exp $
*
* General SGML Parser code SGML.c
* ========================
@@ -2467,9 +2467,17 @@ static void SGML_character(HTStream *me, int c_in)
*/
testlast = string->size - 2 - me->trailing_spaces - me->leading_spaces;
+#ifdef USE_COLOR_STYLE
+#define TagSize(p) ((p)->name_len)
+#else
+#define TagSize(p) (strlen((p)->name))
+#endif
+
if (TOUPPER(c) != ((testlast < 0)
? '/'
- : testtag->name[testlast])) {
+ : ((testlast < (int) TagSize(testtag))
+ ? testtag->name[testlast]
+ : 0))) {
int i;
/*
diff --git a/src/GridText.c b/src/GridText.c
index 7d15191c..7a36b47c 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: GridText.c,v 1.329 2021/06/29 22:01:12 tom Exp $
+ * $LynxId: GridText.c,v 1.334 2021/10/24 16:13:59 tom Exp $
*
* Character grid hypertext object
* ===============================
@@ -784,8 +784,7 @@ static int StyleToCols(HText *text, HTLine *line, int nstyle)
*/
static void LYClearHiText(TextAnchor *a)
{
- FREE(a->lites.hl_info);
-
+ a->lites.hl_info = NULL;
a->lites.hl_base.hl_text = NULL;
a->lites.hl_len = 0;
}
@@ -849,7 +848,7 @@ static int LYAdjHiTextPos(TextAnchor *a, int count)
else
result = a->lites.hl_base.hl_text;
- return (result != 0) ? (int) (LYSkipBlanks(result) - result) : 0;
+ return (result != NULL) ? (int) (LYSkipBlanks(result) - result) : 0;
}
#else
@@ -3006,7 +3005,7 @@ static void split_line(HText *text, unsigned split)
ctrl_chars_on_this_line += utfxtra_on_this_line;
/* Add the data to the new line. -FM */
- strcat(linedata, p);
+ for (i = 0; (linedata[i] = p[i]) != '\0'; ++i) ;
line->size = (unsigned short) (line->size + plen);
}
}
@@ -4109,8 +4108,10 @@ void HText_appendCharacter(HText *text, int ch)
return;
#endif
} else if (ch == LY_SOFT_NEWLINE) {
- line->data[line->size++] = LY_SOFT_NEWLINE;
- line->data[line->size] = '\0';
+ if (line->size < MAX_LINE) {
+ line->data[line->size++] = LY_SOFT_NEWLINE;
+ line->data[line->size] = '\0';
+ }
return;
}
@@ -4147,10 +4148,12 @@ void HText_appendCharacter(HText *text, int ch)
+ UTFXTRA_ON_THIS_LINE == 0)
HText_appendCharacter(text, LY_SOFT_NEWLINE);
}
- line->data[line->size++] = (char) ch;
- line->data[line->size] = '\0';
- utfxtra_on_this_line++;
- ctrl_chars_on_this_line++;
+ if (line->size < MAX_LINE) {
+ line->data[line->size++] = (char) ch;
+ line->data[line->size] = '\0';
+ utfxtra_on_this_line++;
+ ctrl_chars_on_this_line++;
+ }
#ifdef EXP_WCWIDTH_SUPPORT
/* update utfxtracells_on_this_line on last byte of UTF-8 sequence */
{
@@ -4302,6 +4305,8 @@ void HText_appendCharacter(HText *text, int ch)
} else {
for (; here < target; here++) {
/* Put character into line */
+ if (line->size >= MAX_LINE)
+ break;
line->data[line->size++] = ' ';
line->data[line->size] = '\0';
}
@@ -4465,7 +4470,9 @@ void HText_appendCharacter(HText *text, int ch)
line = text->last_line; /* May have changed */
- if (IS_CJK_TTY && text->kanji_buf) {
+ if (line->size >= MAX_LINE) {
+ ;
+ } else if (IS_CJK_TTY && text->kanji_buf) {
hi = UCH(text->kanji_buf);
lo = UCH(ch);
@@ -8091,7 +8098,7 @@ static AnchorIndex **allocAnchorIndex(unsigned *size)
p->filler = ' ';
break;
}
- p->length = (int) strlen(p->value);
+ p->length = p->value ? (int) strlen(p->value) : 0;
if ((q = result[anchor->line_num]) != NULL) {
/* insert, ordering by offset */
@@ -8197,7 +8204,7 @@ void print_wwwfile_to_fd(FILE *fp,
inx = allocAnchorIndex(&inx_size);
line = FirstHTLine(HTMainText);
- for (line_num = 0;; ++line_num, line = line->next) {
+ for (line_num = 0; line != NULL; ++line_num, line = line->next) {
if (in_field >= 0) {
this_wrap = next_wrap;
next_wrap = 0; /* FIXME - allow for multiple continuations */
diff --git a/src/HTML.c b/src/HTML.c
index 083b4cc0..a0124668 100644
--- a/src/HTML.c
+++ b/src/HTML.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: HTML.c,v 1.195 2021/07/23 20:23:54 tom Exp $
+ * $LynxId: HTML.c,v 1.196 2021/10/24 19:10:57 tom Exp $
*
* Structured stream to Rich hypertext converter
* ============================================
@@ -6753,7 +6753,8 @@ static int HTML_end_element(HTStructured * me, int element_number,
*cp = '\0';
StrAllocCopy(temp, data);
*cp = '\n';
- data = (cp + 1);
+ data = NULL; /* HTML_put_characters may overwrite this */
+ StrAllocCopy(data, cp + 1);
} else {
if (*data != '\0') {
StrAllocCopy(temp, data);
@@ -6827,6 +6828,9 @@ static int HTML_end_element(HTStructured * me, int element_number,
FREE(temp);
}
}
+ if (data != empty) {
+ FREE(data);
+ }
FREE(temp);
cp = NULL;
me->UsePlainSpace = FALSE;
diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c
index 288e5108..00139893 100644
--- a/src/LYCharUtils.c
+++ b/src/LYCharUtils.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: LYCharUtils.c,v 1.136 2021/06/29 22:01:12 tom Exp $
+ * $LynxId: LYCharUtils.c,v 1.137 2021/10/24 00:47:08 tom Exp $
*
* Functions associated with LYCharSets.c and the Lynx version of HTML.c - FM
* ==========================================================================
@@ -2912,8 +2912,11 @@ int LYLegitimizeHREF(HTStructured * me, char **href,
p = StrChr(p, '\0');
*pound = '#'; /* restore */
convert_to_spaces(pound, FALSE);
- if (p < pound)
- strcpy(p, pound);
+ if (p < pound) {
+ int n;
+
+ for (n = 0; (p[n] = pound[n]) != '\0'; ++n) ;
+ }
}
}
}
diff --git a/src/LYStrings.c b/src/LYStrings.c
index 8cb33394..67c0b2b0 100644
--- a/src/LYStrings.c
+++ b/src/LYStrings.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYStrings.c,v 1.278 2021/06/09 22:29:17 tom Exp $ */
+/* $LynxId: LYStrings.c,v 1.279 2021/10/24 09:05:19 tom Exp $ */
#include <HTUtils.h>
#include <HTCJK.h>
#include <UCAux.h>
@@ -2755,8 +2755,10 @@ char *LYRemoveBlanks(char *buffer)
*/
char *LYSkipBlanks(char *buffer)
{
- while (isspace(UCH((*buffer))))
- buffer++;
+ if (buffer != NULL) {
+ while (isspace(UCH((*buffer))))
+ buffer++;
+ }
return buffer;
}
@@ -2765,8 +2767,10 @@ char *LYSkipBlanks(char *buffer)
*/
char *LYSkipNonBlanks(char *buffer)
{
- while (*buffer != 0 && !isspace(UCH((*buffer))))
- buffer++;
+ if (buffer != NULL) {
+ while (*buffer != 0 && !isspace(UCH((*buffer))))
+ buffer++;
+ }
return buffer;
}
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 1378287d..0838c78c 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: LYUtils.c,v 1.299 2021/06/09 21:46:53 tom Exp $
+ * $LynxId: LYUtils.c,v 1.300 2021/10/24 16:25:12 tom Exp $
*/
#include <HTUtils.h>
#include <HTTCP.h>
@@ -2969,7 +2969,7 @@ BOOLEAN inlocaldomain(void)
if (ulen > strlen(LYLocalDomain) &&
!memcmp(LYLocalDomain,
me.ut_host + ulen - strlen(LYLocalDomain),
- ulen)) {
+ strlen(LYLocalDomain))) {
result = TRUE;
}
#ifdef LINUX
diff --git a/src/TRSTable.c b/src/TRSTable.c
index bc7e2e50..2a9461c8 100644
--- a/src/TRSTable.c
+++ b/src/TRSTable.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: TRSTable.c,v 1.38 2020/01/21 22:19:58 tom Exp $
+ * $LynxId: TRSTable.c,v 1.39 2021/10/24 18:05:05 tom Exp $
* Simple table object
* ===================
* Authors
@@ -444,7 +444,7 @@ static int Stbl_addCellToRow(STable_rowinfo *me, STable_cellinfo *colinfo, int n
{
int growby = 0;
- while (me->ncells + colspan + 1 > me->allocated + growby)
+ while (me->ncells + colspan + 1 >= me->allocated + growby)
growby += CELLS_GROWBY;
if (growby) {
if (me->allocated == 0 && !me->cells) {
@@ -1064,7 +1064,7 @@ int Stbl_addRowToTable(STable_info *me, int alignment,
int i;
int growby = 0;
- while (me->nrows + 2 > me->allocated_rows + growby)
+ while (me->nrows + 2 >= me->allocated_rows + growby)
growby += ROWS_GROWBY;
if (growby) {
if (me->allocated_rows == 0 && !me->rows) {
@@ -1473,7 +1473,7 @@ int Stbl_addCellToTable(STable_info *me, int colspan,
{
int growby = 0;
- while (icell + colspan + 1 > me->allocated_sumcols + growby)
+ while (icell + colspan + 1 >= me->allocated_sumcols + growby)
growby += CELLS_GROWBY;
if (growby) {
if (me->allocated_sumcols == 0 && !me->sumcols) {
@@ -1669,7 +1669,7 @@ int Stbl_addColInfo(STable_info *me,
{
int growby = 0;
- while (icolinfo + colspan + 1 > me->allocated_sumcols + growby)
+ while (icolinfo + colspan + 1 >= me->allocated_sumcols + growby)
growby += CELLS_GROWBY;
if (growby) {
if (me->allocated_sumcols == 0) {