Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
aeb1b0cd
Commit
aeb1b0cd
authored
11 years ago
by
Arne Goedeke
Browse files
Options
Downloads
Patches
Plain Diff
Inotify: do not assume that strings are aligned
parent
3a04ee7d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/Inotify/inotify.cmod
+16
-12
16 additions, 12 deletions
src/modules/Inotify/inotify.cmod
with
16 additions
and
12 deletions
src/modules/Inotify/inotify.cmod
+
16
−
12
View file @
aeb1b0cd
...
@@ -111,8 +111,9 @@ DECLARATIONS
...
@@ -111,8 +111,9 @@ DECLARATIONS
*! @endarray
*! @endarray
*/
*/
PIKEFUN
array
(
string
|
int
)
parse_event
(
string
data
)
{
PIKEFUN
array
(
string
|
int
)
parse_event
(
string
data
)
{
struct
inotify_event
*
event
;
struct
inotify_event
event
;
size_t
len
;
size_t
len
;
const
char
*
d
;
if
(
data
->
size_shift
)
if
(
data
->
size_shift
)
Pike_error
(
"Inotify events should not be wide.
\n
"
);
Pike_error
(
"Inotify events should not be wide.
\n
"
);
...
@@ -120,21 +121,24 @@ PIKEFUN array(string|int) parse_event(string data) {
...
@@ -120,21 +121,24 @@ PIKEFUN array(string|int) parse_event(string data) {
if
((
size_t
)
data
->
len
<
sizeof
(
struct
inotify_event
))
if
((
size_t
)
data
->
len
<
sizeof
(
struct
inotify_event
))
Pike_error
(
"Malformed data.
\n
"
);
Pike_error
(
"Malformed data.
\n
"
);
event
=
(
struct
inotify_event
*
)
data
->
str
;
d
=
data
->
str
;
if
(
event
->
len
>
data
->
len
-
sizeof
(
struct
inotify_event
))
memcpy
(
&
event
,
d
,
sizeof
(
struct
inotify_event
));
Pike_error
(
"Data missing.
\n
"
);
push_int
(
(
int
)
event
->
wd
);
push_int
(
event
.
wd
);
push_int
((
int
)
event
->
mask
);
push_int
((
int
)
event
.
mask
);
push_int
((
int
)
event
->
cookie
);
push_int
((
int
)
event
.
cookie
);
if
(
event
->
len
&&
(
len
=
strlen
(
event
->
name
)))
if
(
event
.
len
)
{
push_string
(
make_shared_binary_string
(
event
->
name
,
len
));
if
(
event
.
len
>
data
->
len
-
sizeof
(
struct
inotify_event
))
else
Pike_error
(
"Data missing. Got %u expected %u bytes.
\n
"
,
(
unsigned
)(
data
->
len
-
sizeof
(
struct
inotify_event
)),
event
.
len
);
d
+=
sizeof
(
struct
inotify_event
);
push_string
(
make_shared_binary_string
(
d
,
strnlen
(
d
,
event
.
len
)));
}
else
{
push_int
(
0
);
push_int
(
0
);
}
push_int
((
int
)(
event
->
len
+
sizeof
(
struct
inotify_event
)));
push_int
((
int
)(
event
.
len
+
sizeof
(
struct
inotify_event
)));
f_aggregate
(
5
);
f_aggregate
(
5
);
stack_swap
();
stack_swap
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment