[GRASS-git] [OSGeo/grass] 84db88: lib/gis: Add portable G_strlcpy function (#4101)

Loïc Bartoletti noreply at github.com
Mon Jul 29 10:02:55 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: 84db88a9d2b7e05fdb5472b118986ece263b6615
      https://github.com/OSGeo/grass/commit/84db88a9d2b7e05fdb5472b118986ece263b6615
  Author: Loïc Bartoletti <lbartoletti at users.noreply.github.com>
  Date:   2024-07-29 (Mon, 29 Jul 2024)

  Changed paths:
    M configure
    M configure.ac
    M include/grass/config.h.in
    M include/grass/defs/gis.h
    A lib/gis/strlcpy.c

  Log Message:
  -----------
  lib/gis: Add portable G_strlcpy function (#4101)

This commit introduces a new G_strlcpy function in lib/gis, inspired by
G_asprintf. G_strlcpy provides a safer alternative to strcpy and strncpy,
with consistent behavior across different systems.

Key points:
- Implements strlcpy functionality, available natively on BSD systems
- Portable implementation for non-BSD systems (excluding Linux with libbsd)
- Based on FreeBSD's implementation:
  https://github.com/freebsd/freebsd-src/blob/98dd639c94f716858ae29958f484729b1d2fd387/sys/libkern/strlcpy.c#L28
- Designed to replace unsafe uses of strcpy and strncpy throughout the project

The function is implemented to use the native strlcpy where available,
falling back to our portable version on systems without it. This ensures
optimal performance on BSD systems while maintaining compatibility across
different platforms.

By providing G_strlcpy, we aim to improve the overall safety and
consistency of string operations in our codebase.



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