FreeBSD Bugzilla – Attachment 164240 Details for
Bug 205322
[PATCH] boot0cfg: check result of the malloc()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
check malloc result
0001-boot0cfg-check-result-of-malloc.patch (text/plain), 961 bytes, created by
Alexander Kuleshov
on 2015-12-14 18:24:10 UTC
(
hide
)
Description:
check malloc result
Filename:
MIME Type:
Creator:
Alexander Kuleshov
Created:
2015-12-14 18:24:10 UTC
Size:
961 bytes
patch
obsolete
>From d74ca94afd85cb11d33afe9cce87be96d770f55e Mon Sep 17 00:00:00 2001 >From: Alexander Kuleshov <kuleshovmail@gmail.com> >Date: Mon, 14 Dec 2015 23:49:26 +0600 >Subject: [PATCH] boot0cfg: check result of malloc() > >We are trying to allocate buffer for MBR by the call of >the malloc(). The malloc() returns NULL in an error case. >This patch provides check for this case. >--- > usr.sbin/boot0cfg/boot0cfg.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > >diff --git a/usr.sbin/boot0cfg/boot0cfg.c b/usr.sbin/boot0cfg/boot0cfg.c >index 2602e50..052be94 100644 >--- a/usr.sbin/boot0cfg/boot0cfg.c >+++ b/usr.sbin/boot0cfg/boot0cfg.c >@@ -336,7 +336,8 @@ read_mbr(const char *disk, u_int8_t **mbr, int check_version) > close(fd); > return (mbr_size); > } >- *mbr = malloc(sizeof(buf)); >+ if ((*mbr = malloc(sizeof(buf))) == NULL) >+ errx(1, "%s: unable to allocate MBR buffer", disk); > memcpy(*mbr, buf, sizeof(buf)); > close(fd); > >-- >2.6.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 205322
: 164240