]> granicus.if.org Git - procps-ng/commitdiff
ps/output.c: Check return value of mmap() in init_output().
authorQualys Security Advisory <qsa@qualys.com>
Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)
committerCraig Small <csmall@enc.com.au>
Fri, 18 May 2018 21:32:21 +0000 (07:32 +1000)
We decided not to check the return value of the mprotect() calls,
because they are not vital to the operation of ps.

ps/output.c

index 4456f282d85aeb902822e82b6ce0c44fd218e540..01b8765879f859766f0d339529d9d81fdf73ce86 100644 (file)
@@ -2169,6 +2169,9 @@ void init_output(void){
     -1,
     0
   );
+  if(outbuf == MAP_FAILED)
+    catastrophic_failure(__FILE__, __LINE__, _("please report this bug"));
+
   memset(outbuf, ' ', SPACE_AMOUNT);
   if(SPACE_AMOUNT==page_size) mprotect(outbuf, page_size, PROT_READ);
   mprotect(outbuf + page_size*outbuf_pages, page_size, PROT_NONE); // guard page