git.ucc.asn.au
/
tpg
/
acess2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
28e517c
)
Syscalls - Changed SysGetMessage to provide a buffer size
author
John Hodge
<
[email protected]
>
Thu, 4 Oct 2012 13:41:13 +0000
(21:41 +0800)
committer
John Hodge
<
[email protected]
>
Thu, 4 Oct 2012 13:41:13 +0000
(21:41 +0800)
KernelLand/Kernel/include/threads.h
patch
|
blob
|
history
KernelLand/Kernel/messages.c
patch
|
blob
|
history
KernelLand/Kernel/syscalls.c
patch
|
blob
|
history
Usermode/Applications/axwin3_src/WM/ipc.c
patch
|
blob
|
history
Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c
patch
|
blob
|
history
Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h
patch
|
blob
|
history
diff --git
a/KernelLand/Kernel/include/threads.h
b/KernelLand/Kernel/include/threads.h
index
0362cdb
..
6382cf0
100644
(file)
--- a/
KernelLand/Kernel/include/threads.h
+++ b/
KernelLand/Kernel/include/threads.h
@@
-37,6
+37,6
@@
extern char **Threads_GetCWD(void);
extern char **Threads_GetChroot(void);
extern int Proc_SendMessage(Uint Dest, int Length, void *Data);
extern char **Threads_GetChroot(void);
extern int Proc_SendMessage(Uint Dest, int Length, void *Data);
-extern int Proc_GetMessage(Uint *Source, void *Buffer);
+extern int Proc_GetMessage(Uint *Source,
Uint BufSize,
void *Buffer);
#endif
#endif
diff --git
a/KernelLand/Kernel/messages.c
b/KernelLand/Kernel/messages.c
index
09c8c14
..
c991978
100644
(file)
--- a/
KernelLand/Kernel/messages.c
+++ b/
KernelLand/Kernel/messages.c
@@
-78,10
+78,11
@@
int Proc_SendMessage(Uint Dest, int Length, void *Data)
* \fn int Proc_GetMessage(Uint *Source, void *Buffer)
* \brief Gets a message
* \param Source Where to put the source TID
* \fn int Proc_GetMessage(Uint *Source, void *Buffer)
* \brief Gets a message
* \param Source Where to put the source TID
+ * \param BufSize Size of \a Buffer, only this many bytes will be copied
* \param Buffer Buffer to place the message data (set to NULL to just get message length)
* \return Message length
*/
* \param Buffer Buffer to place the message data (set to NULL to just get message length)
* \return Message length
*/
-int Proc_GetMessage(Uint *Source, void *Buffer)
+int Proc_GetMessage(Uint *Source,
Uint BufSize,
void *Buffer)
{
int ret;
void *tmp;
{
int ret;
void *tmp;
@@
-113,7
+114,7
@@
int Proc_GetMessage(Uint *Source, void *Buffer)
// Get message
if(Buffer != GETMSG_IGNORE)
{
// Get message
if(Buffer != GETMSG_IGNORE)
{
- if( !CheckMem( Buffer,
cur->Messages->Length
) )
+ if( !CheckMem( Buffer,
BufSize
) )
{
LOG("Invalid buffer");
errno = -EINVAL;
{
LOG("Invalid buffer");
errno = -EINVAL;
@@
-121,8
+122,15
@@
int Proc_GetMessage(Uint *Source, void *Buffer)
LEAVE('i', -1);
return -1;
}
LEAVE('i', -1);
return -1;
}
+ if( BufSize < cur->Messages->Length )
+ Log_Notice("Threads", "Buffer of 0x%x passed, but 0x%x long message, truncated",
+ BufSize, cur->Messages->Length);
+ else if( BufSize < cur->Messages->Length )
+ BufSize = cur->Messages->Length;
+ else
+ ; // equal
LOG("Copied to buffer");
LOG("Copied to buffer");
- memcpy(Buffer, cur->Messages->Data,
cur->Messages->Length
);
+ memcpy(Buffer, cur->Messages->Data,
BufSize
);
}
ret = cur->Messages->Length;
}
ret = cur->Messages->Length;
diff --git
a/KernelLand/Kernel/syscalls.c
b/KernelLand/Kernel/syscalls.c
index
0348d57
..
bfd68bf
100644
(file)
--- a/
KernelLand/Kernel/syscalls.c
+++ b/
KernelLand/Kernel/syscalls.c
@@
-135,13
+135,10
@@
void SyscallHandler(tSyscallRegs *Regs)
// -- Check for messages
case SYS_GETMSG:
CHECK_NUM_NULLOK( (Uint*)Regs->Arg1, sizeof(Uint) );
// -- Check for messages
case SYS_GETMSG:
CHECK_NUM_NULLOK( (Uint*)Regs->Arg1, sizeof(Uint) );
- // NOTE: Can't do range checking as we don't know the size
- // - Should be done by Proc_GetMessage
- if( Regs->Arg2 && Regs->Arg2 != -1 && !MM_IsUser(Regs->Arg2) ) {
- err = -EINVAL; ret = -1; break;
- }
+ if( Regs->Arg3 != -1 )
+ CHECK_NUM_NULLOK((void*)Regs->Arg3, Regs->Arg2);
// *Source, *Data
// *Source, *Data
- ret = Proc_GetMessage((Uint*)Regs->Arg1,
(void*)Regs->Arg2
);
+ ret = Proc_GetMessage((Uint*)Regs->Arg1,
Regs->Arg2, (void*)Regs->Arg3
);
break;
// -- Get the current timestamp
break;
// -- Get the current timestamp
diff --git
a/Usermode/Applications/axwin3_src/WM/ipc.c
b/Usermode/Applications/axwin3_src/WM/ipc.c
index
cbed7fd
..
1d4ac33
100644
(file)
--- a/
Usermode/Applications/axwin3_src/WM/ipc.c
+++ b/
Usermode/Applications/axwin3_src/WM/ipc.c
@@
-112,12
+112,12
@@
void IPC_HandleSelect(fd_set *set)
}
}
}
}
- while(SysGetMessage(NULL, NULL))
+ size_t len;
+ pid_t tid;
+ while( (len = SysGetMessage(&tid, 0, NULL)) )
{
{
- pid_t tid;
- int len = SysGetMessage(&tid, NULL);
char data[len];
char data[len];
- SysGetMessage(NULL, data);
+ SysGetMessage(NULL,
len,
data);
IPC_Handle(&gIPC_Type_SysMessage, &tid, len, (void*)data);
// _SysDebug("IPC_HandleSelect: Message handled");
IPC_Handle(&gIPC_Type_SysMessage, &tid, len, (void*)data);
// _SysDebug("IPC_HandleSelect: Message handled");
diff --git
a/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c
b/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c
index
2b50167
..
ac51e27
100644
(file)
--- a/
Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c
+++ b/
Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c
@@
-127,7
+127,7
@@
tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void)
pid_t tid;
// Wait for a message to arrive
pid_t tid;
// Wait for a message to arrive
- while( !(len = SysGetMessage(&tid, NULL)) )
+ while( !(len = SysGetMessage(&tid,
0,
NULL)) )
{
_SysWaitEvent(THREAD_EVENT_IPCMSG);
}
{
_SysWaitEvent(THREAD_EVENT_IPCMSG);
}
@@
-140,7
+140,7
@@
tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void)
if( gAxWin3_MessageCallback )
gAxWin3_MessageCallback(tid, len);
else
if( gAxWin3_MessageCallback )
gAxWin3_MessageCallback(tid, len);
else
- SysGetMessage(NULL, GETMSG_IGNORE);
+ SysGetMessage(NULL,
0,
GETMSG_IGNORE);
continue ;
}
continue ;
}
@@
-148,10
+148,10
@@
tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void)
ret = malloc(len);
if(ret == NULL) {
_SysDebug("malloc() failed, ignoring message");
ret = malloc(len);
if(ret == NULL) {
_SysDebug("malloc() failed, ignoring message");
- SysGetMessage(NULL, GETMSG_IGNORE);
+ SysGetMessage(NULL,
0,
GETMSG_IGNORE);
return NULL;
}
return NULL;
}
- SysGetMessage(NULL, ret);
+ SysGetMessage(NULL,
len,
ret);
break;
}
break;
break;
}
break;
diff --git
a/Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h
b/Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h
index
1a954d3
..
2452972
100644
(file)
--- a/
Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h
+++ b/
Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h
@@
-85,7
+85,7
@@
extern int unlink(const char *pathname);
// --- IPC ---
extern int SysSendMessage(pid_t dest, uint length, const void *Data);
// --- IPC ---
extern int SysSendMessage(pid_t dest, uint length, const void *Data);
-extern int SysGetMessage(pid_t *src, void *Data);
+extern int SysGetMessage(pid_t *src,
uint buflen,
void *Data);
// --- MEMORY ---
uint64_t _SysGetPhys(uint vaddr);
// --- MEMORY ---
uint64_t _SysGetPhys(uint vaddr);
UCC
git Repository :: git.ucc.asn.au