Skip to content

feat: safe sscanf #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2025
Merged

Conversation

ColinKYuen
Copy link
Contributor

@ColinKYuen ColinKYuen commented Apr 12, 2025

Summary

Replaces the usages of sscanf() for a safer implementation

Description

For character strings, the standard library uses the convention that strings are null-terminated: a string of n characters is represented as an array of n + 1 elements, the last of which is a NUL character ('\0'). For input conversion to various types, the C library provides the scanf() function family. The scanf() family of functions scans input according to supplied format string. This format may contain conversion specifications; the results from such conversions, if any, are stored in the locations pointed to by the pointer arguments that follow format. Each pointer argument must be of a type that is appropriate for the value returned by the corresponding conversion specification. scanf() also does not check the bounds of the inputs and may cause buffer overflows.

Testing

The regression tests have been built on

  • Windows 11, 24H2
  • Linux, Ubuntu 24
  • & M4 Max Mac, Sequoia 15.3.2

The test results match what is currently on mainline

@davecramer davecramer merged commit 0600769 into postgresql-interfaces:main Apr 15, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants