lkml.org 
[lkml]   [2000]   [Oct]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Problem with msgsnd

On Thu, 26 Oct 2000 17:15:30 Marc Schneider wrote:
> lkml@dm.ultramaster.com wrote:
> >
> > Marc Schneider wrote:
> > >
> > > msgsnd seems to be corrupting memory around the msgbuf pointer.
> > >
> > > for example I have the following code:
> > >
> > > pMsgBuf = malloc(iPacketLen + 4 + 8);
> > > bzero(pMsgBuf, iPacketLen + 4 + 8);
> > > pMsgBuf += 4; /* Build a guard band */
> > >
> > > printf("PMQ:pMsgBuf: %p\n",pMsgBuf);
> > > printf("PMQ:-4: %p\n", *(pMsgBuf-4));
> > >

Silly question: why do you :

printf("PMQ:-4: %p\n", *(pMsgBuf-4));

instead of:
!!!
printf("PMQ:-4: %d\n", *(pMsgBuf-4));, or whatever applies...(typeof pMsgBuf?)

If you use %p, printf expects a pointer in stack, and depending on type of
pMsgBuf (is a char * ?), *pMsgBuf can be passed as a char (I don't think so,
C passes chars as ints, and I dont remenber any kind of option to modify this)
or a short or an int...

So, perhaps you dont put enough data on stack for a pointer and printf gets
incorrect data (the zero in pMsgBuf plus the return value that stored in rc...).

--
Juan Antonio Magallon Lacarta mailto:jamagallon@able.es

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:43    [W:0.039 / U:2.536 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site