Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • BIND BIND
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 577
    • Issues 577
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 116
    • Merge requests 116
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • ISC Open Source ProjectsISC Open Source Projects
  • BINDBIND
  • Issues
  • #277
Closed
Open
Issue created May 18, 2018 by Michael McNally@McNally

isc__print_printf omits characters after %f

Summary

Another submission from Infoblox, who would like us to know that isc__print_printf omits characters after %f

Steps to reproduce

Jinmei says:

Try this test code and see the second ATF_CHECK_STREQ() fail. I believe that should be enough to explain the problem (the first chunk of ATF_CHECK_xx is actually irrelevant to the bug; I added it just to first confirm a more basic case) .

float pi = 3.141;
n = isc_print_snprintf(buf, sizeof(buf), "%.2f", pi);
ATF_CHECK_EQ(n, 4);
ATF_CHECK_STREQ(buf, "3.14");

/* Similar to the above, but additional characters follows */
n = isc_print_snprintf(buf, sizeof(buf), "%.2f1592", pi);
ATF_CHECK_EQ(n, 8);
ATF_CHECK_STREQ(buf, "3.141592");

Possible fixes

The following patch would fix this issue. The same problem seems to exist for other versions than 9.11.3-S1, too.

diff --git a/lib/isc/print.c b/lib/isc/print.c
index 55843c4..5588e13 100644
--- a/lib/isc/print.c
+++ b/lib/isc/print.c
@@ -685,7 +685,7 @@ isc__print_printf(void (*emit)(char, void *), void *arg,
pad--;
}
cp = buf;
- while (*cp != ' ')
+ while (*cp != '\0' && *cp != ' ')
emit(*cp++, arg);
while (pad > 0) {
emit(' ', arg);
Assignee
Assign to
Time tracking