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 Jul 23, 2024
1 parent 5952770 commit 8f9937d
Show file tree
Hide file tree
Showing 20 changed files with 97 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
# COPYRIGHT: (C) 2002-2024 by the GRASS Development Team
=======
# COPYRIGHT: (C) 2002-2022 by the GRASS Development Team
Expand All @@ -22,6 +23,9 @@
=======
# COPYRIGHT: (C) 2002-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (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))
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
Expand Down
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
# COPYRIGHT: (C) 2000-2024 by the GRASS Development Team
=======
# COPYRIGHT: (C) 2000-2022 by the GRASS Development Team
Expand All @@ -22,6 +23,9 @@
=======
# COPYRIGHT: (C) 2000-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (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))
#
# This program is free software under the GNU General
# Public License (>=v2). Read the file COPYING that
Expand Down
8 changes: 8 additions & 0 deletions grasslib.dox
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
* updated 8/2005, 2006-2024
=======
Expand All @@ -22,6 +23,9 @@
=======
* updated 8/2005, 2006-2008, 2010-2011, 2017-2023
>>>>>>> 021dfb5d52 (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))
-->

<a href="https://grass.osgeo.org">GRASS GIS</a> (<b>Geographic
Expand All @@ -46,6 +50,7 @@ pages.
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
&copy; 2000-2024 by the GRASS Development Team
=======
&copy; 2000-2022 by the GRASS Development Team
Expand All @@ -56,6 +61,9 @@ pages.
=======
&copy; 2000-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (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))

This manual is published under <a
href="http://www.fsf.org/copyleft/fdl.html">GNU Free Documentation
Expand Down
5 changes: 5 additions & 0 deletions imagery/i.maxlik/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ int main(int argc, char *argv[])
*/
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
if (Rast_is_c_null_value(&class_cell[col]) == 0)
class_cell[col] = S.sig[class_cell[col] - 1].oclass;
Expand All @@ -153,6 +154,10 @@ int main(int argc, char *argv[])
if (Rast_is_c_null_value(&class_cell[col]) == 0)
class_cell[col] = S.sig[class_cell[col] - 1].oclass;
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
=======
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))
}
}
Rast_put_row(class_fd, class_cell, CELL_TYPE);
Expand Down
4 changes: 4 additions & 0 deletions imagery/i.maxlik/testsuite/test_i_maxlik.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def setUpClass(cls):
"r.mapcalc",
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
expression=f"{cls.b2}=if(row() == 3 && col() == 3, null(), 5.0+rand(-1.0,1.0))",
=======
Expand All @@ -79,6 +80,9 @@ 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))
=======
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))
flags="s",
quiet=True,
)
Expand Down
4 changes: 4 additions & 0 deletions include/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ dev
=======
3
dev
<<<<<<< HEAD
2022
>>>>>>> 8422103f4c (wxpyimgview: explicit conversion to int (#2704))
=======
2023
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
=======
2023
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
4 changes: 4 additions & 0 deletions include/grass/gis.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
* COPYRIGHT: (C) 2000-2024 by the GRASS Development Team
=======
Expand All @@ -27,6 +28,9 @@
=======
* COPYRIGHT: (C) 2000-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (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))
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
Expand Down
4 changes: 4 additions & 0 deletions lib/gis/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
(C) 2001-2024 by the GRASS Development Team
=======
Expand All @@ -16,6 +17,9 @@
=======
(C) 2001-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (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))
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
Expand Down
4 changes: 4 additions & 0 deletions lib/gis/gislib_cmdline_parsing.dox
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extracted form gislib.dox and improved by Vaclav Petras, 2013
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
Copyright 2004-2024 by the GRASS Development Team
=======
Copyright 2004-2022 by the GRASS Development Team
Expand All @@ -17,6 +18,9 @@ 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))
=======
Copyright 2004-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))

Published under GNU Free Documentation License
-->
Expand Down
4 changes: 4 additions & 0 deletions lib/gis/parser_html.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
(C) 2001-2024 by the GRASS Development Team
=======
Expand All @@ -16,6 +17,9 @@
=======
(C) 2001-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (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))
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
Expand Down
4 changes: 4 additions & 0 deletions lib/init/grass.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
# COPYRIGHT: (C) 2000-2024 by the GRASS Development Team
=======
# COPYRIGHT: (C) 2000-2022 by the GRASS Development Team
Expand All @@ -31,6 +32,9 @@
=======
# COPYRIGHT: (C) 2000-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (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))
#
# This program is free software under the GNU General
# Public License (>=v2). Read the file COPYING that
Expand Down
4 changes: 4 additions & 0 deletions lib/init/grass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
# COPYRIGHT: (C) 2000-2024 by the GRASS Development Team
=======
# COPYRIGHT: (C) 2000-2022 by the GRASS Development Team
Expand All @@ -26,6 +27,9 @@
=======
# COPYRIGHT: (C) 2000-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (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))
#
# This program is free software under the GNU General
# Public License (>=v2). Read the file COPYING that
Expand Down
4 changes: 4 additions & 0 deletions man/build_graphical_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
# COPYRIGHT: (C) 2015-2024 by Vaclav Petras and the GRASS Development Team
=======
# COPYRIGHT: (C) 2015-2022 by Vaclav Petras and the GRASS Development Team
Expand All @@ -18,6 +19,9 @@
=======
# COPYRIGHT: (C) 2015-2023 by Vaclav Petras and the GRASS Development Team
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
=======
# COPYRIGHT: (C) 2015-2023 by Vaclav Petras and the GRASS Development Team
>>>>>>> 6104ec7096 (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
4 changes: 4 additions & 0 deletions man/build_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
# (C) 2003-2024 Markus Neteler and the GRASS Development Team
=======
# (C) 2003-2022 Markus Neteler and the GRASS Development Team
Expand All @@ -14,6 +15,9 @@
=======
# (C) 2003-2023 Markus Neteler and the GRASS Development Team
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
=======
# (C) 2003-2023 Markus Neteler and the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
# Authors:
# Markus Neteler
# Glynn Clements
Expand Down
8 changes: 8 additions & 0 deletions man/build_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
# (C) 2003-2024 by Luca Delucchi and the GRASS Development Team
=======
# (C) 2003-2022 by Luca Delucchi and the GRASS Development Team
Expand All @@ -22,6 +23,9 @@
=======
# (C) 2003-2023 by Luca Delucchi and the GRASS Development Team
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
=======
# (C) 2003-2023 by Luca Delucchi and the GRASS Development Team
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))

import os
import string
Expand Down Expand Up @@ -183,6 +187,7 @@
:doc:`Manual main page <index>` \| :doc:`Full Index <full_index>`
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
2003-2024 `GRASS Development Team <https://grass.osgeo.org>`_, GRASS GIS ${grass_version} Reference Manual
""" # noqa: E501
Expand All @@ -193,6 +198,9 @@
=======
2003-2023 `GRASS Development Team <https://grass.osgeo.org>`_, GRASS GIS ${grass_version} Reference Manual
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
=======
2003-2023 `GRASS Development Team <https://grass.osgeo.org>`_, GRASS GIS ${grass_version} Reference Manual
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))
"""
>>>>>>> 6cf60c76a4 (wxpyimgview: explicit conversion to int (#2704))
)
Expand Down
8 changes: 8 additions & 0 deletions man/sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@
>>>>>>> 6cf60c76a4 (wxpyimgview: explicit conversion to int (#2704))
=======
project = "GRASS GIS 8.3 Documentation"
<<<<<<< HEAD
copyright = "2022, GRASS Development Team"
>>>>>>> 8422103f4c (wxpyimgview: explicit conversion to int (#2704))
=======
copyright = "2023, GRASS Development Team"
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
=======
copyright = "2023, GRASS Development Team"
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -426,11 +430,15 @@
epub_title = "GRASS GIS 8.3 Documentation"
epub_author = "GRASS Development Team"
epub_publisher = "GRASS Development Team"
<<<<<<< HEAD
epub_copyright = "2022, GRASS Development Team"
>>>>>>> 8422103f4c (wxpyimgview: explicit conversion to int (#2704))
=======
epub_copyright = "2023, GRASS Development Team"
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
=======
epub_copyright = "2023, GRASS Development Team"
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))

# The language of the text. It defaults to the language option
# or en if the language is not set.
Expand Down
8 changes: 8 additions & 0 deletions python/grass/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
copyright = "2024, GRASS Development Team"
=======
copyright = "2022, GRASS Development Team"
Expand All @@ -141,6 +142,9 @@
=======
copyright = "2023, GRASS Development Team"
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
=======
copyright = "2023, GRASS Development Team"
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -379,6 +383,7 @@
=======
epub_publisher = "GRASS Development Team"
<<<<<<< HEAD
<<<<<<< HEAD
epub_copyright = "2022, GRASS Development Team"
<<<<<<< HEAD
>>>>>>> 6cf60c76a4 (wxpyimgview: explicit conversion to int (#2704))
Expand All @@ -387,6 +392,9 @@
=======
epub_copyright = "2023, GRASS Development Team"
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
=======
epub_copyright = "2023, GRASS Development Team"
>>>>>>> 6104ec7096 (i.maxlik: fix crash when classification result is NULL (#2724))

# The basename for the epub file. It defaults to the project name.
# epub_basename = u'wxGUI'
Expand Down
4 changes: 4 additions & 0 deletions python/grass/script/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
(C) 2008-2024 by the GRASS Development Team
=======
(C) 2008-2021 by the GRASS Development Team
Expand All @@ -29,6 +30,9 @@
=======
(C) 2008-2023 by the GRASS Development Team
>>>>>>> 021dfb5d52 (r.terrafow: explicit use of default constructors (#2660))
=======
(C) 2008-2023 by the GRASS Development Team
>>>>>>> 6104ec7096 (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 8f9937d

Please sign in to comment.