This discussion is archived
0 Replies Latest reply: Oct 19, 2011 6:25 PM by 895363 RSS

Issue with vsnprintf not getting fixed with LD_PRELOAD

895363 Newbie
Currently Being Moderated
Hi,
We are facing an issue with the "vsnprintf" function on Solaris after porting from HP.

This happens in no argument condition for "vsnprintf". Please find below the detailed code snippet ( sample program which we are replicating) and the machine details it is being run on below.
This fails even with setting "export LD_PRELOAD=/usr/lib/0@0.so.1" or " -z interpose /usr/lib/0@0.so.1".

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>

char make_message(char str,const char *fmt, ...);
char str[80];

int main(void)
{
const char *one = "this";
const char *two = "is";
const char *three = "becoming a string";
const char *four = "last but not the least";
char *result = NULL;
const char *fmt = "%s %s %s";

result = make_message(str,fmt);
if(result == NULL)
{
fprintf(stderr, "Error - make_message(...) == NULL\n");
return 1;
}
else
{
printf("%s\n", result);
free(result);
}
}

char make_message(char str,const char *fmt, ...)
{
size_t size = 80;
int n =0;
va_list ap;
va_list ap2;


va_start(ap, fmt);
va_copy(ap2, ap);
n = vsnprintf(str, size, fmt, ap2);
va_end(ap2);
va_end(ap);

return str;
}



Output details:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1) Server Type : SunOS <machine-name> 5.10 Generic_142900-12 sun4u sparc SUNW,SPARC-Enterprise

2) Binary compiled using /users/solstudio12.2/bin/CC
CC -z interpose /usr/lib/0@0.so.1 -o sample sample.c

3) Run the program
./sample
Segmentation Fault(coredump)

4) pldd core

core 'core' of 9580: ./sample
/usr/lib/0@0.so.1
/usr/lib/libCstd.so.1
/usr/lib/libCrun.so.1
/lib/libm.so.2
/lib/libc.so.1
/usr/lib/cpu/sparcv8plus/libCstd_isa.so.1
/platform/sun4u-opl/lib/libc_psr.so.1

5) pflags core

core 'core' of 9580: ./sample
data model = _ILP32  flags = MSACCT|MSFORK
/1: flags = 0
sigmask = 0xffffbefc,0x0000ffff cursig = SIGSEGV

6)pstack core

fef321d0 strlen (1118b, ffbfda68, ffbfd251, ee274, 0, 0) + 50
fefa0084 vsnprintf (213f8, 50, 11189, ffbfda64, 7ffffc00, fefb647c) + 6c
00010f94 __1cMmake_message6FpcpkcE_0_ (213f8, 11189, ee274, ff356e8c, ff170780, 213a4) + 34
00010edc main (1, ffbfdafc, ffbfdb04, 21000, ff170700, 0) + 4c
00010a60 _start   (0, 0, 0, 0, 0, 0) + 108
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

PS : Any normal strlen function with NULL pointer being passed, passes if LD_PRELOAD is being set for the same server.


Kindly help me out. This is on urgent priority.
Thanks.

Regards,
Dip

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points