Ticket #122 (closed defect: fixed)

Opened 12 months ago

Last modified 12 months ago

bots_main.c: sprintf() should be snprintf()

Reported by: Nathan Weeks <weeks@…> Owned by:
Priority: critical Milestone: version 1.2
Component: common Version: version 1.1.1
Keywords: Cc:
Application Version: not applicable Blocked By:
Blocking: Sensitive: no
Needs experiment: no
Experimental observations:

Description

The fix for /ticket 117
introduced a bug: an sprintf() that is called when "MANUAL_CUTOFF",
"IF_CUTOFF", or "FINAL_CUTOFF" are defined had its arguments changed to those
of snprintf(), but the function call itself wasn't changed. This can cause a
compilation error or segmentation fault at run time.

Patch:

$ diff -u common/bots_main.c.orig common/bots_main.c
--- common/bots_main.c.orig     Thu Feb 10 07:41:35 2011
+++ common/bots_main.c  Tue Feb 22 20:58:23 2011
@@ -460,11 +460,11 @@
    snprintf(bots_ldflags, BOTS_TMP_STR_SZ, LDFLAGS);

 #if defined(MANUAL_CUTOFF)
-   sprintf(bots_cutoff, BOTS_TMP_STR_SZ, "manual (%d)",bots_cutoff_value);
+   snprintf(bots_cutoff, BOTS_TMP_STR_SZ, "manual (%d)",bots_cutoff_value);
 #elif defined(IF_CUTOFF)
-   sprintf(bots_cutoff, BOTS_TMP_STR_SZ, "pragma-if (%d)",bots_cutoff_value);
+   snprintf(bots_cutoff, BOTS_TMP_STR_SZ, "pragma-if (%d)",bots_cutoff_value);
 #elif defined(FINAL_CUTOFF)
-   sprintf(bots_cutoff, BOTS_TMP_STR_SZ, "final (%d)",bots_cutoff_value);
+   snprintf(bots_cutoff, BOTS_TMP_STR_SZ, "final (%d)",bots_cutoff_value);
 #else
    strcpy(bots_cutoff,"none");
 #endif

Change History

Changed 12 months ago by ALEX DURAN <aduran@…>

  • status changed from new to closed
  • resolution set to fixed

(In [a32e8a9766183e3b51756ba654f9177508840ff2]) Fix problem calling sprintf instead of snprintf (closes #122)

Note: See TracTickets for help on using tickets.