- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- problem with vsprintf
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-11-2007 08:49 PM
тАО06-11-2007 08:49 PM
When I try to compile the following code, I get an additional message from the buffer.
The code that we use has,
buf[0] = '\0';
va_start(va, fmt);
vsprintf(buf, fmt, va);
va_end(va);
len = fprintf(work,"%s",buf);
The buffer should only contain the content of fmt. But, it also contains the text "parent information" along with the content of fmt. i.e, if the value of fmt is "hi", the value of buf should also be "hi". But the actual value that we get is, "parent informationhi".
Please help.
Thanks,
nan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-11-2007 09:01 PM
тАО06-11-2007 09:01 PM
Re: problem with vsprintf
You don't need this. The following seems fine:
va_start(va, fmt);
vsprintf(buf, fmt, va);
va_end(va);
>The buffer should only contain the content of fmt. But, it also contains the text "parent information" along with the content of fmt.
It shouldn't have this. What is in fmt?
len = fprintf(work,"%s",buf);
It is silly to use fprintf(%s), you should call fputs or fwrite. Or you could have called vfprintf to start with.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-11-2007 09:07 PM
тАО06-11-2007 09:07 PM
Re: problem with vsprintf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-11-2007 09:36 PM
тАО06-11-2007 09:36 PM
SolutionWhat you are saying can't happen unless you have your own bogus version of vsprintf.
If you set a breakpoint on vsprintf, are you in libc when you hit it? What does "bt" give?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-11-2007 09:58 PM
тАО06-11-2007 09:58 PM
Re: problem with vsprintf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-11-2007 11:17 PM
тАО06-11-2007 11:17 PM
Re: problem with vsprintf
how is the variable buf declared?
Does 'buf' point to an allocated chunk of memory big enough to hold the varargs?
Best use vsnprintf() in that cases because not buffer overrun can occure when correctly used.
mfG Peter