diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2009-01-26 23:24:07 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2009-01-26 23:24:07 +0100 |
commit | b6850a9e3cd988829e5d09918928ef5aa9b4e731 (patch) | |
tree | cab075d3e5e065b53e903dc95d2d5bca526f10be /inotify-watch.c | |
parent | cbab5e56df05da42ddeb4839005b77c7da2688d4 (diff) |
Check inev->len before printing name
Diffstat (limited to 'inotify-watch.c')
-rw-r--r-- | inotify-watch.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/inotify-watch.c b/inotify-watch.c index ccedf2f..1a32786 100644 --- a/inotify-watch.c +++ b/inotify-watch.c @@ -3,7 +3,7 @@ * * Watch a file or directory for changes using inotify * - * Copyright (c) Tobias Klauser <tklauser@distanz.ch> + * Copyright (c) 2008-2009 Tobias Klauser <tklauser@distanz.ch> * * All rights reserved. */ @@ -21,7 +21,7 @@ struct mask2string { const char *desc; }; -static struct mask2string events[] = { +static const struct mask2string events[] = { { IN_ACCESS, "ACCESS" }, { IN_MODIFY, "MODIFY" }, { IN_ATTRIB, "ATTRIB" }, @@ -53,7 +53,8 @@ static void inotify_print_event(struct inotify_event *inev) /* stat? */ printf("(%s) wd=%04x, cookie=%04x, len=%04x, name=\"%s\" :", inev->mask & IN_ISDIR ? "dir" : "file", - inev->wd, inev->cookie, inev->len, inev->name); + inev->wd, inev->cookie, inev->len, + inev->len > 0 ? inev->name : ""); for (i = 0; events[i].desc; i++) if (inev->mask & events[i].mask) |