[GRASS-git] [OSGeo/grass] d788ee: i.atcorr: fix out of bound access in trunca, os an...

Mohan Yelugoti noreply at github.com
Thu Oct 17 21:31:50 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: d788eee193b3e3a4d10194775cec9d4429802403
      https://github.com/OSGeo/grass/commit/d788eee193b3e3a4d10194775cec9d4429802403
  Author: Mohan Yelugoti <ymdatta.work at gmail.com>
  Date:   2024-10-18 (Fri, 18 Oct 2024)

  Changed paths:
    M imagery/i.atcorr/computations.cpp

  Log Message:
  -----------
  i.atcorr: fix out of bound access in trunca, os and iso (#4493)

* i.atcorr: fix out of bound access in trunca, os and iso

In trunca(), under 2 if conditionals (if rumu[1] > 0.8 and
rmu[1] > 0.94), k and kk values are set to -1 respectively.
When these values are used to access an array, it leads
to out of bound access, which is undefined behavior in c++.

Similarly in os() and iso(), if `taup < h[i]` for all values,
iplane would still be -1 and we would be accessing an array
with this as an index, which is undefined behavior.

In both cases, to avoid that, set that index to zero.

This was found using cppcheck tool.

Signed-off-by: Mohan Yelugoti <ymdatta.work at gmail.com>

* Update imagery/i.atcorr/computations.cpp

When plane layer couldn't be determined, throw out an error and exit.

Co-authored-by: Markus Metz <33666869+metzm at users.noreply.github.com>

* Update imagery/i.atcorr/computations.cpp

When plane layer couldn't be determined, throw out an error and exit.

Co-authored-by: Markus Metz <33666869+metzm at users.noreply.github.com>

* Fix clang-format issues

Signed-off-by: Mohan Yelugoti <ymdatta.work at gmail.com>

---------

Signed-off-by: Mohan Yelugoti <ymdatta.work at gmail.com>
Co-authored-by: Markus Metz <33666869+metzm at users.noreply.github.com>



To unsubscribe from these emails, change your notification settings at https://github.com/OSGeo/grass/settings/notifications


More information about the grass-commit mailing list