Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 288730
b: refs/heads/master
c: 62db906
h: refs/heads/master
v: v3
  • Loading branch information
Stephane Eranian authored and Ingo Molnar committed Mar 9, 2012
1 parent 7a5f88f commit 015ae38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 69996df486fc3921bbaaa17fca0d68f537f9eabf
refs/heads/master: 62db90681c0db8c76e5db006b929a2edd5d12ae6
19 changes: 9 additions & 10 deletions trunk/tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -1144,8 +1144,9 @@ static void print_event_desc(struct perf_header *ph, int fd, FILE *fp)
uint64_t id;
void *buf = NULL;
char *str;
u32 nre, sz, nr, i, j, msz;
int ret;
u32 nre, sz, nr, i, j;
ssize_t ret;
size_t msz;

/* number of events */
ret = read(fd, &nre, sizeof(nre));
Expand All @@ -1162,25 +1163,23 @@ static void print_event_desc(struct perf_header *ph, int fd, FILE *fp)
if (ph->needs_swap)
sz = bswap_32(sz);

/*
* ensure it is at least to our ABI rev
*/
if (sz < (u32)sizeof(attr))
goto error;

memset(&attr, 0, sizeof(attr));

/* read entire region to sync up to next field */
/* buffer to hold on file attr struct */
buf = malloc(sz);
if (!buf)
goto error;

msz = sizeof(attr);
if (sz < msz)
if (sz < (ssize_t)msz)
msz = sz;

for (i = 0 ; i < nre; i++) {

/*
* must read entire on-file attr struct to
* sync up with layout.
*/
ret = read(fd, buf, sz);
if (ret != (ssize_t)sz)
goto error;
Expand Down

0 comments on commit 015ae38

Please sign in to comment.