>>> Wenchao Hao <[email protected]> schrieb am 07.12.2020 um 02:54 in >>> Nachricht <[email protected]>: > If malloc() returns NULL on fail, we should return -ENOMEM to > avoid NULL pointer dereference. > > Signed-off-by: Wenchao Hao <[email protected]> > Signed-off-by: Zhiqiang Liu <[email protected]> > Signed-off-by: Wu Bo <[email protected]> > --- > usr/mgmt_ipc.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c > index c292161..054378e 100644 > --- a/usr/mgmt_ipc.c > +++ b/usr/mgmt_ipc.c > @@ -453,8 +453,11 @@ mgmt_ipc_read_req(queue_task_t *qtask) > /* Remember the allocated pointer in the > * qtask - it will be freed by write_rsp. > * Note: we allocate one byte in excess > - * so we can append a NUL byte. */ > + * so we can append a NULL byte. */
Nitpick: "NUL" is a well-defined ACSII character, while NULL is a well-defined C pointer. Thus I'd keep NUL. > qtask->payload = malloc(req->payload_len + 1); > + if (!qtask->payload) > + return -ENOMEM; > + > rc = mgmt_ipc_read_data(qtask->mgmt_ipc_fd, > qtask->payload, > req->payload_len); > -- > 2.27.0 > > -- > You received this message because you are subscribed to the Google Groups > "open-iscsi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/open-iscsi/20201207015410.48488-6-haowencha > o%40huawei.com. -- You received this message because you are subscribed to the Google Groups "open-iscsi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/open-iscsi/5FCF3A5F020000A10003D5BB%40gwsmtp.uni-regensburg.de.
