From 159d3bdfd5ccef3da1485ebdf315ecc66fe3e4f9 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Sun, 25 Mar 2012 13:48:22 +0400 Subject: [PATCH] fdinfo: Sanitize types in fdinfo_entry The namelen is u16, to cover the PATH_MAX u8 is not enough. The pos is u64, since file offset is that long indeed. The id is u32 as per previous patch. Fix printf-s respectively. Signed-off-by: Pavel Emelyanov --- cr-show.c | 4 ++-- files.c | 2 +- include/image.h | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cr-show.c b/cr-show.c index ff594bd19..448ad149a 100644 --- a/cr-show.c +++ b/cr-show.c @@ -83,8 +83,8 @@ static void show_files(int fd_files) if (ret <= 0) goto out; - pr_msg("type: %s flags: %4x pos: %8x " - "addr: %16lx id: %8lx", + pr_msg("type: %s flags: %4x pos: %lx " + "addr: %16lx id: %8x", fdtype2s(e.type), e.flags, e.pos, e.addr, e.id); if (e.len) { diff --git a/files.c b/files.c index 8d070f8b1..3f76ca634 100644 --- a/files.c +++ b/files.c @@ -76,7 +76,7 @@ static int collect_fd(int pid, struct fdinfo_entry *e) struct fdinfo_list_entry *le = &fdinfo_list[nr_fdinfo_list]; struct fdinfo_desc *desc; - pr_info("Collect fdinfo pid=%d fd=%ld id=%16lx\n", + pr_info("Collect fdinfo pid=%d fd=%ld id=%16x\n", pid, e->addr, e->id); nr_fdinfo_list++; diff --git a/include/image.h b/include/image.h index f2daae9d9..0145c10b9 100644 --- a/include/image.h +++ b/include/image.h @@ -46,11 +46,11 @@ enum fd_types { struct fdinfo_entry { u8 type; - u8 len; + u16 len; u16 flags; - u32 pos; + u64 pos; u64 addr; - u64 id; + u32 id; u8 name[0]; } __packed;