1820072 Members
2655 Online
109608 Solutions
New Discussion юеВ

vsnprintf in HP-UX

 
Vineesh U S
Occasional Advisor

vsnprintf in HP-UX

Hi Team,
I understand that vsnprintf function in HP-UX is broken.

I have some code which uses vsnprintf function and running on HP. Is there any alternative to these functions?

Is there any solution/ workaroud for this issue?

thanks and regards
vuz
5 REPLIES 5
Gregory Fruth
Esteemed Contributor

Re: vsnprintf in HP-UX

vsnprintf works fine for me. If it's
broken on your machine perhaps you ought
to be looking for patches relating to it.
Vineesh U S
Occasional Advisor

Re: vsnprintf in HP-UX

Hi all,
My environment is HP-UX 11i.
uname -a gives me
HP-UX jesser01 B.11.11 U 9000/800 2640277115 unlimited-user license

Here I see that the vsnprintf is giving me some errors. could I know what are the patches I need to apply for vsnprintf to work???

Background information: I am porting an application running on Solaris to HP-UX and in this code the vsnprintf is giving me errors.

Thanks and regards
vuz
Gregory Fruth
Esteemed Contributor

Re: vsnprintf in HP-UX

You need to give more information on
what you think your problem is. When you
say "errors" do you mean compile-time errors
or run-time errors? What does vsnprintf
do (or not do) that you think it shouldn't
(or should)?

As for patches, go look up "vsnprintf"
or "stdarg" in the patch database.
Vineesh U S
Occasional Advisor

Re: vsnprintf in HP-UX

Hi,
Thank you for your support.
I had run a program as below. Here, while running on my platform I always get the value of len < 0 and it signals an error.

static int
set_env(const char *format, ...)
{
va_list ap;
char dummy_buf[64];
int istat, len;
char *ptr;

/*
* Init the va_list
*/
va_start(ap, format);

len = vsnprintf(dummy_buf, sizeof(dummy_buf)-1, format, ap);
if (len <= 0)
{
va_end(ap);
return((len < 0) ? -1 : 0);
}

/*

.
.
.
.
.
.
.
}

Why is this so?
Your comments on this snippet shall be appreciated.

Thanks and regards
vineesh
Ermin Borovac
Honored Contributor

Re: vsnprintf in HP-UX

I think this line

len = vsnprintf(dummy_buf, sizeof(dummy_buf)-1, format, ap);

should read

len = vsnprintf(dummy_buf, sizeof(dummy_buf), format, ap);

You will get len < 0 when you overflow dummy_buf.