Bug 1133 - snprintf replacement function has conflicting type
Summary: snprintf replacement function has conflicting type
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Build system (show other bugs)
Version: -current
Hardware: HPPA HP-UX
: P2 major
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-16 12:08 AEDT by David Leonard
Modified: 2006-10-07 11:43 AEST (History)
1 user (show)

See Also:


Attachments
autoconf.ac patch to use BROKEN_VSNPRINTF (553 bytes, patch)
2005-12-16 12:09 AEDT, David Leonard
no flags Details | Diff
configure test for SNPRINTF_CONST (1.38 KB, patch)
2005-12-16 12:53 AEDT, David Leonard
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Leonard 2005-12-16 12:08:51 AEDT
The autoconf.ac test for a broken vsnprintf sets BROKEN_SNPRINTF instead of BROKEN_VSNPRINTF.

This causes breakage on HP-UX 11.00, because the (otherwise usable) snprintf prototype in stdio.h doesn't agree with the replacement provided by OpenSSH.

Output from openssh-SNAP-20051213's configure is:

  checking whether snprintf correctly terminates long strings... yes
  checking whether vsnprintf returns correct values on overflow... no
  configure: WARNING: ****** Your vsnprintf() function is broken, complain to your vendor

The config.h file contains no BROKEN_VSNPRINTF at all

    $ grep PRINTF config.h 
    #define BROKEN_SNPRINTF 1
    /* #undef HAVE_ASPRINTF */
    #define HAVE_SNPRINTF 1
    /* #undef HAVE_VASPRINTF */
    #define HAVE_VSNPRINTF 1

Build fails here:

    gcc -g -O2 -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -std=gnu99  -I. -I.. -I. -I./..  -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 -DHAVE_CONFIG_H -c bsd-snprintf.c
    bsd-snprintf.c:792: error: conflicting types for `snprintf'
    /usr/local/lib/gcc-lib/hppa2.0n-hp-hpux11.00/3.3.2/include/stdio.h:493: error: previous declaration of `snprintf'
    *** Error exit code 1

[Credit to Ted Percival for finding this]
Comment 1 David Leonard 2005-12-16 12:09:51 AEDT
Created attachment 1042 [details]
autoconf.ac patch to use BROKEN_VSNPRINTF
Comment 2 Ted Percival 2005-12-16 12:42:31 AEDT
In response to the attachment "autoconf.ac patch to use BROKEN_VSNPRINTF" created 2005-12-16 12:09, it should also have the next line changed, "snprintf" to "vsnprintf".
Comment 3 David Leonard 2005-12-16 12:46:18 AEDT
(In reply to comment #2)

yeah actually, that patch was just totally wrong.
Comment 4 David Leonard 2005-12-16 12:53:25 AEDT
Created attachment 1043 [details]
configure test for SNPRINTF_CONST

This seems to work better. (Only tested on hpux)
Comment 5 David Leonard 2005-12-16 12:57:40 AEDT
correct summary
Comment 6 Darren Tucker 2005-12-17 22:32:35 AEDT
Applied patch #1043, thanks.

Note that vsnprintf on HP-UX (tested 11.11) does not return the number of bytes that should have been written, it returns the number of bytes that *were* written, thus you cannot detect truncation.
Comment 7 Darren Tucker 2006-10-07 11:43:41 AEST
Change all RESOLVED bug to CLOSED with the exception of the ones fixed post-4.4.