Skip to content

Commit 1cdd3b8

Browse files
author
Shishir Jaiswal
committed
Bug #20359808 - OUT OF BOUNDS WRITE (OFF BY ONE)
DESCRIPTION =========== /strings/ctype.c: In cs_value() for one of the cases (Rules: Context), the length check condition is flawed. With current behaviour it allows the program to write even if length of "attribute" is equal to size of "context" which results in memory corruption. This happens since the extra terminating NULL is written at the start of the adjacent variable. ANALYSIS ======== The program should allow to write it only if the length of former is less than size of latter. So the "+ 1" should be dropped from the following condition: if (len < sizeof(i->context) + 1) In the regular scenario when program writes well within its boundary, this corruption doesn't happen. FIX === Dropped "+ 1" from the condition so that the required check is made correctly.
1 parent 3b6b4bf commit 1cdd3b8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

strings/ctype.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -752,7 +752,7 @@ static int cs_value(MY_XML_PARSER *st,const char *attr, size_t len)
752752

753753
/* Rules: Context */
754754
case _CS_CONTEXT:
755-
if (len < sizeof(i->context) + 1)
755+
if (len < sizeof(i->context))
756756
{
757757
memcpy(i->context, attr, len);
758758
i->context[len]= '\0';

0 commit comments

Comments
 (0)