[GRASS-git] [OSGeo/grass] 373ece: lib/gis: set buffer to G_format_[northing|easting|...

R Sai Pranav noreply at github.com
Tue Sep 29 13:37:49 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: 373ece55af0ada334a5d16ef0ec116b0c288641f
      https://github.com/OSGeo/grass/commit/373ece55af0ada334a5d16ef0ec116b0c288641f
  Author: R Sai Pranav <rajasaipranav0 at gmail.com>
  Date:   2026-09-29 (Tue, 29 Sep 2026)

  Changed paths:
    M display/d.where/where.c
    M lib/gis/wind_format.c
    M ps/ps.map/map_info.c
    M raster/r.coin/print_hdr.c
    M raster/r.report/header.c

  Log Message:
  -----------
  lib/gis: set buffer to G_format_[northing|easting|resolution] to >=320 bytes (#7943)

Bound the buffers G_format_northing/easting/resolution write into

format_double() (lib/gis/wind_format.c) formats a coordinate with
sprintf(buf, "%.8f", value) for any non-lat/lon projection. %.8f on a
double has no fixed maximum width -- DBL_MAX needs 318 characters --
but several callers pass a fixed local buffer sized for an ordinary
coordinate: 30 bytes in r.coin, 50 in r.report, ps.map, and d.where.

g.region's coordinate parser (scan_double() in wind_scan.c) is a bare
sscanf with no magnitude check, so an extreme n=/s=/e=/w= value in a
non-lat/lon projection is accepted, and the region's stored coordinate
can be large enough to overflow these buffers when one of the four
affected programs formats it.

Reproduced with format_double() extracted verbatim into a standalone
harness under AddressSanitizer: 9e19 (29-char result) is clean, 1e20
(30 characters, one more than a 30-byte buffer can hold with the
terminator) overflows. DBL_MAX needs exactly 318 characters, measured
directly.

Bumped each of the four buffers to 320 bytes -- sign + DBL_MAX's 318
digits + the terminator -- rather than changing format_double()'s
signature, which is called from many places across the tree with no
size parameter today and felt like a separate, bigger decision. Fixes
#7942.

Signed-off-by: sai pranav <rajasaipranav0 at gmail.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