From b6850a9e3cd988829e5d09918928ef5aa9b4e731 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 26 Jan 2009 23:24:07 +0100 Subject: Check inev->len before printing name --- inotify-watch.c | 7 ++++--- 1 file 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 + * Copyright (c) 2008-2009 Tobias Klauser * * 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) -- cgit v1.2.3-54-g00ecf