summaryrefslogtreecommitdiff
blob: 2d79c7293f9d3a4f5f88c5d0c09e12698daa6100 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
https://hg.openindiana.org/upstream/oracle/userland-gate/raw-file/23c55a2f8a8e/components/top/patches/03.sunos5.patch

--- a/machine/m_sunos5.c
+++ b/machine/m_sunos5.c
@@ -2064,7 +2064,13 @@ getptable (struct prpsinfo *baseptr)
 
 	    /* read the whole file */
 	    p = malloc(st.st_size);
-	    (void)pread(fd, p, st.st_size, 0);
+	    if (pread(fd, p, st.st_size, 0) != st.st_size)
+	    {
+		(void) close(fd);
+		op->fd_lpsinfo = -1;
+		free(p);
+		continue;
+	    }
 
 	    /* cache the file descriptor if we can */
 	    if (fd < maxfiles)
@@ -2148,7 +2154,7 @@ getptable (struct prpsinfo *baseptr)
 		op->oldtime = TIMESPEC_TO_DOUBLE(lwpp->pr_time);
 		op->seen = 1;
 	    }
-	    free(p);
+	    free(prp);
 	}
 #endif