HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- memcpy( ) behaviour on 11i HP-UX machine
Operating System - HP-UX
1833784
Members
2398
Online
110063
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
10-29-2002 07:18 PM
10-29-2002 07:18 PM
memcpy( ) behaviour on 11i HP-UX machine
This is regarding the memcpy() function
used on HP-UX 11.11 machine. memcpy ()
takes 3 parameters. First two are
strings and third one is no. of bytes
to be copied. If we pass the third
argument a negative number I.e. number
of bytes to be copy is negative then it
works fine with HP-UX v10.2 and v11.0
but fails (give segmentation fault
core) on 11i HP-UX machine.
Why is this scenario?
used on HP-UX 11.11 machine. memcpy ()
takes 3 parameters. First two are
strings and third one is no. of bytes
to be copied. If we pass the third
argument a negative number I.e. number
of bytes to be copy is negative then it
works fine with HP-UX v10.2 and v11.0
but fails (give segmentation fault
core) on 11i HP-UX machine.
Why is this scenario?
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2002 01:54 AM
10-30-2002 01:54 AM
Re: memcpy( ) behaviour on 11i HP-UX machine
???
How would you define 'working fine while copying negative number of bytes'? This function should do something exept from returning without core.
Actually I belive that core gewnerating is 'working fine with such argument' (to be precise - I assume you're not trying to copy more that 2 GB of memory), so the previous behaviour is simply a bug.
Regards
Adam
How would you define 'working fine while copying negative number of bytes'? This function should do something exept from returning without core.
Actually I belive that core gewnerating is 'working fine with such argument' (to be precise - I assume you're not trying to copy more that 2 GB of memory), so the previous behaviour is simply a bug.
Regards
Adam
I do everything perfectly, except from my mistakes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2002 02:09 AM
10-30-2002 02:09 AM
Re: memcpy( ) behaviour on 11i HP-UX machine
Actually the scenario is like this:
My program logic calls memcpy funtion:
call memcpy(char *str1, char *str2, int count);
As per the logic of the program this count equal to -1. Which logically should not be the case. But we diidn't come across any problem when we ran our program on HP-UX 10.2 and HP-UX 11.0. But hen we ported it to HP-UX 11.11, our program generated a core. On debugging we found out that actually program logic is trying to copy negative byte using memcpy and while doing so it is generating core.
Then we prepared a small program which simply uses memcpy function. We found out that in HP-UX 10.2 and HP-UX 11.0, whenever memcpy acounter its third argument negative it treats it as zero. But in 11.11 HP -UX it genrated segmentation fault core dump.
I want to know that is this a bug or is it an enhancement of HP-UX 11.11 machine.
Is there a patch available for this or do I have to provide a check before memcpy() function that throw an error when ever third argument (no. of bytes to cpopy) is negative.
Let me know in case of any doubts.
Thanks and regards.
My program logic calls memcpy funtion:
call memcpy(char *str1, char *str2, int count);
As per the logic of the program this count equal to -1. Which logically should not be the case. But we diidn't come across any problem when we ran our program on HP-UX 10.2 and HP-UX 11.0. But hen we ported it to HP-UX 11.11, our program generated a core. On debugging we found out that actually program logic is trying to copy negative byte using memcpy and while doing so it is generating core.
Then we prepared a small program which simply uses memcpy function. We found out that in HP-UX 10.2 and HP-UX 11.0, whenever memcpy acounter its third argument negative it treats it as zero. But in 11.11 HP -UX it genrated segmentation fault core dump.
I want to know that is this a bug or is it an enhancement of HP-UX 11.11 machine.
Is there a patch available for this or do I have to provide a check before memcpy() function that throw an error when ever third argument (no. of bytes to cpopy) is negative.
Let me know in case of any doubts.
Thanks and regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2002 03:01 AM
10-30-2002 03:01 AM
Re: memcpy( ) behaviour on 11i HP-UX machine
from /usr/inclue/string.h:
extern void *memcpy(void *, const void *, size_t);
from: /usr/include/sys/_size_t.h:
typedef unsigned long size_t;
If you are interested in how much bytes are you trying to copy use:
printf( "Number of bytes: %lu\n", (unsigned long) -1L );
Why did it work before? I don't know, but I think it shouldn't also.
Hope this exhaust your doubts. :)
Adam
extern void *memcpy(void *, const void *, size_t);
from: /usr/include/sys/_size_t.h:
typedef unsigned long size_t;
If you are interested in how much bytes are you trying to copy use:
printf( "Number of bytes: %lu\n", (unsigned long) -1L );
Why did it work before? I don't know, but I think it shouldn't also.
Hope this exhaust your doubts. :)
Adam
I do everything perfectly, except from my mistakes
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP