PRE(sys_open)
{
- HChar name[30];
- SysRes sres;
-
if (ARG2 & VKI_O_CREAT) {
// 3-arg version
PRINT("sys_open ( %#lx(%s), %ld, %ld )",ARG1,(char*)ARG1,ARG2,ARG3);
/proc/<pid>/cmdline, and just give it a copy of the fd for the
fake file we cooked up at startup (in m_main). Also, seek the
cloned fd back to the start. */
+ {
+ HChar name[30];
+ Char* arg1s = (Char*) ARG1;
+ SysRes sres;
- VG_(sprintf)(name, "/proc/%d/cmdline", VG_(getpid)());
- if (ML_(safe_to_deref)( (void*)ARG1, 1 )
- && (VG_(strcmp)((Char *)ARG1, name) == 0
- || VG_(strcmp)((Char *)ARG1, "/proc/self/cmdline") == 0)) {
- sres = VG_(dup)( VG_(cl_cmdline_fd) );
- SET_STATUS_from_SysRes( sres );
- if (!sr_isError(sres)) {
- OffT off = VG_(lseek)( sr_Res(sres), 0, VKI_SEEK_SET );
- if (off < 0)
- SET_STATUS_Failure( VKI_EMFILE );
+ VG_(sprintf)(name, "/proc/%d/cmdline", VG_(getpid)());
+ if (ML_(safe_to_deref)( arg1s, 1 ) &&
+ (VG_STREQ(arg1s, name) || VG_STREQ(arg1s, "/proc/self/cmdline"))
+ )
+ {
+ sres = VG_(dup)( VG_(cl_cmdline_fd) );
+ SET_STATUS_from_SysRes( sres );
+ if (!sr_isError(sres)) {
+ OffT off = VG_(lseek)( sr_Res(sres), 0, VKI_SEEK_SET );
+ if (off < 0)
+ SET_STATUS_Failure( VKI_EMFILE );
+ }
+ return;
}
- return;
}
/* Otherwise handle normally */