From 2e285845ea03c5505092b8de5f6097e5845b25ec Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 7 Aug 2018 22:49:16 +0200 Subject: [PATCH] smbd: Fix CID 1438246 Unchecked return value BUG: https://bugzilla.samba.org/show_bug.cgi?id=13553 Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/smbd/nttrans.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 810f8b92b43..bad904b9eb8 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -2317,6 +2317,7 @@ static enum ndr_err_code fill_qtlist_from_sids(TALLOC_CTX *mem_ctx, for (i = 0; i < elems; i++) { SMB_NTQUOTA_STRUCT qt; SMB_NTQUOTA_LIST *list_item; + bool ok; if (!NT_STATUS_IS_OK(vfs_get_ntquota(fsp, SMB_USER_QUOTA_TYPE, @@ -2333,7 +2334,15 @@ static enum ndr_err_code fill_qtlist_from_sids(TALLOC_CTX *mem_ctx, return NDR_ERR_ALLOC; } - sid_to_uid(&sids[i], &list_item->uid); + ok = sid_to_uid(&sids[i], &list_item->uid); + if (!ok) { + char buf[DOM_SID_STR_BUFLEN]; + dom_sid_string_buf(&sids[i], buf, sizeof(buf)); + DBG_WARNING("Could not convert SID %s to uid\n", buf); + /* No idea what to return here... */ + return NDR_ERR_INVALID_POINTER; + } + list_item->quotas = talloc_zero(list_item, SMB_NTQUOTA_STRUCT); if (list_item->quotas == NULL) { DBG_ERR("failed to allocate\n"); -- 2.47.2