Skip to content

Commit

Permalink
i.maxlik: fix crash when classification result is NULL (OSGeo#2724)
Browse files Browse the repository at this point in the history
If any input cell from imagery group is NULL, the result of classification is also NULL. The implementation of original cat restoration (79f9500) did not check for this corner case and thus caused an out of bounds value access.
  • Loading branch information
a0x8o committed Jun 17, 2024
1 parent a7fe10f commit 0b1431f
Show file tree
Hide file tree
Showing 20 changed files with 210 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
# COPYRIGHT: (C) 2002-2023 by the GRASS Development Team
=======
<<<<<<< HEAD
Expand All @@ -32,6 +33,8 @@
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
# COPYRIGHT: (C) 2002-2024 by the GRASS Development Team
=======
# COPYRIGHT: (C) 2002-2022 by the GRASS Development Team
Expand All @@ -45,6 +48,7 @@
# COPYRIGHT: (C) 2002-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
<<<<<<< HEAD
<<<<<<< HEAD
=======
# COPYRIGHT: (C) 2002-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
Expand All @@ -64,6 +68,11 @@
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
=======
# COPYRIGHT: (C) 2002-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
Expand Down
9 changes: 9 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
# COPYRIGHT: (C) 2000-2023 by the GRASS Development Team
=======
<<<<<<< HEAD
Expand All @@ -32,6 +33,8 @@
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
# COPYRIGHT: (C) 2000-2024 by the GRASS Development Team
=======
# COPYRIGHT: (C) 2000-2022 by the GRASS Development Team
Expand All @@ -45,6 +48,7 @@
# COPYRIGHT: (C) 2000-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
<<<<<<< HEAD
<<<<<<< HEAD
=======
# COPYRIGHT: (C) 2000-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
Expand All @@ -64,6 +68,11 @@
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
=======
# COPYRIGHT: (C) 2000-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
#
# This program is free software under the GNU General
# Public License (>=v2). Read the file COPYING that
Expand Down
18 changes: 18 additions & 0 deletions grasslib.dox
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
* updated 8/2005, 2006-2008, 2010-2011, 2017-2023
=======
Expand All @@ -32,6 +33,8 @@
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
* updated 8/2005, 2006-2024
=======
* updated 8/2005, 2006-2008, 2010-2011, 2017, 2018, 2019, 2021
Expand All @@ -53,6 +56,7 @@
* updated 8/2005, 2006-2008, 2010-2011, 2017-2023
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
<<<<<<< HEAD
<<<<<<< HEAD
=======
* updated 8/2005, 2006-2008, 2010-2011, 2017-2023
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
Expand All @@ -79,6 +83,11 @@
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
=======
* updated 8/2005, 2006-2008, 2010-2011, 2017-2023
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
-->

<a href="https://grass.osgeo.org">GRASS GIS</a> (<b>Geographic
Expand Down Expand Up @@ -106,6 +115,7 @@ pages.
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
&copy; 2000-2023 by the GRASS Development Team
=======
<<<<<<< HEAD
Expand All @@ -123,6 +133,8 @@ pages.
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
&copy; 2000-2024 by the GRASS Development Team
=======
&copy; 2000-2022 by the GRASS Development Team
Expand All @@ -136,6 +148,7 @@ pages.
&copy; 2000-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
<<<<<<< HEAD
<<<<<<< HEAD
=======
&copy; 2000-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
Expand All @@ -155,6 +168,11 @@ pages.
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
=======
&copy; 2000-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))

This manual is published under <a
href="http://www.fsf.org/copyleft/fdl.html">GNU Free Documentation
Expand Down
9 changes: 9 additions & 0 deletions imagery/i.maxlik/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,11 @@ int main(int argc, char *argv[])
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
if (Rast_is_c_null_value(&class_cell[col]) == 0)
class_cell[col] = S.sig[class_cell[col] - 1].oclass;
=======
Expand Down Expand Up @@ -231,12 +234,16 @@ int main(int argc, char *argv[])
class_cell[col] = S.sig[class_cell[col] - 1].oclass;
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
=======
if (Rast_is_c_null_value(&class_cell[col]) == 0)
class_cell[col] = S.sig[class_cell[col] - 1].oclass;
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
>>>>>>> osgeo-main
=======
>>>>>>> osgeo-main
Expand All @@ -259,6 +266,8 @@ int main(int argc, char *argv[])
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
}
}
Rast_put_row(class_fd, class_cell, CELL_TYPE);
Expand Down
9 changes: 9 additions & 0 deletions imagery/i.maxlik/testsuite/test_i_maxlik.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ def setUpClass(cls):
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
expression=f"{cls.b2}=if(row() == 3 && col() == 3, null(), 5.0+rand(-1.0,1.0))",
=======
<<<<<<< HEAD
Expand Down Expand Up @@ -104,6 +107,7 @@ def setUpClass(cls):
expression=f"{cls.b2}=if(row() == 3 && col() == 3, null(), 5.0+rand(-1.0,1.0))",
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
<<<<<<< HEAD
<<<<<<< HEAD
=======
expression=f"{cls.b2}=if(row() == 3 && col() == 3, null(), 5.0+rand(-1.0,1.0))",
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
Expand All @@ -130,6 +134,11 @@ def setUpClass(cls):
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
=======
expression=f"{cls.b2}=if(row() == 3 && col() == 3, null(), 5.0+rand(-1.0,1.0))",
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
flags="s",
quiet=True,
)
Expand Down
6 changes: 6 additions & 0 deletions include/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ dev
2023
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
<<<<<<< HEAD
<<<<<<< HEAD
=======
2023
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
Expand Down Expand Up @@ -107,3 +108,8 @@ dev
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
=======
2023
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
9 changes: 9 additions & 0 deletions include/grass/gis.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
* COPYRIGHT: (C) 2000-2023 by the GRASS Development Team
=======
Expand All @@ -37,6 +38,8 @@
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
* COPYRIGHT: (C) 2000-2024 by the GRASS Development Team
=======
* COPYRIGHT: (C) 2000-2021 by the GRASS Development Team
Expand All @@ -58,6 +61,7 @@
* COPYRIGHT: (C) 2000-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
<<<<<<< HEAD
<<<<<<< HEAD
=======
* COPYRIGHT: (C) 2000-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
Expand All @@ -84,6 +88,11 @@
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
=======
* COPYRIGHT: (C) 2000-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
Expand Down
9 changes: 9 additions & 0 deletions lib/gis/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
(C) 2001-2023 by the GRASS Development Team
=======
Expand All @@ -26,6 +27,8 @@
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
(C) 2001-2024 by the GRASS Development Team
=======
(C) 2001-2022 by the GRASS Development Team
Expand All @@ -39,6 +42,7 @@
(C) 2001-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
<<<<<<< HEAD
<<<<<<< HEAD
=======
(C) 2001-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
Expand All @@ -58,6 +62,11 @@
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
=======
(C) 2001-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
Expand Down
9 changes: 9 additions & 0 deletions lib/gis/gislib_cmdline_parsing.dox
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extracted form gislib.dox and improved by Vaclav Petras, 2013
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
Copyright 2004-2023 by the GRASS Development Team
=======
<<<<<<< HEAD
Expand All @@ -27,6 +28,8 @@ Copyright 2004-2023 by the GRASS Development Team
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
Copyright 2004-2024 by the GRASS Development Team
=======
Copyright 2004-2022 by the GRASS Development Team
Expand All @@ -40,6 +43,7 @@ Copyright 2004-2022 by the GRASS Development Team
Copyright 2004-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
<<<<<<< HEAD
<<<<<<< HEAD
=======
Copyright 2004-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
Expand All @@ -59,6 +63,11 @@ Copyright 2004-2022 by the GRASS Development Team
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
=======
Copyright 2004-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))

Published under GNU Free Documentation License
-->
Expand Down
9 changes: 9 additions & 0 deletions lib/gis/parser_html.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
(C) 2001-2023 by the GRASS Development Team
=======
Expand All @@ -26,6 +27,8 @@
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
(C) 2001-2024 by the GRASS Development Team
=======
(C) 2001-2022 by the GRASS Development Team
Expand All @@ -39,6 +42,7 @@
(C) 2001-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
<<<<<<< HEAD
<<<<<<< HEAD
=======
(C) 2001-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
Expand All @@ -58,6 +62,11 @@
>>>>>>> a2d9fb4362 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> fc6ae6c77c (r.terrafow: explicit use of default constructors (#2660))
=======
=======
(C) 2001-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
>>>>>>> 630833279b (i.maxlik: fix crash when classification result is NULL (#2724))
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
Expand Down
Loading

0 comments on commit 0b1431f

Please sign in to comment.