bool *allowed = 0;
union srvsvc_NetShareCtr ctr;
uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
+ WERROR ret = WERR_OK;
DEBUG(5,("init_srv_share_info_ctr\n"));
unbecome_root();
allowed = talloc_zero_array(ctx, bool, num_services);
- W_ERROR_HAVE_NO_MEMORY(allowed);
+ if (allowed == NULL) {
+ goto nomem;
+ }
/* Count the number of entries. */
for (snum = 0; snum < num_services; snum++) {
}
if (!num_entries || (resume_handle >= num_entries)) {
- return WERR_OK;
+ goto done;
}
/* Calculate alloc entries. */
switch (info_ctr->level) {
case 0:
ctr.ctr0 = talloc_zero(ctx, struct srvsvc_NetShareCtr0);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr0);
+ if (ctr.ctr0 == NULL) {
+ goto nomem;
+ }
ctr.ctr0->count = alloc_entries;
ctr.ctr0->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo0, alloc_entries);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr0->array);
+ if (ctr.ctr0->array == NULL) {
+ goto nomem;
+ }
for (snum = 0; snum < num_services; snum++) {
if (allowed[snum] &&
case 1:
ctr.ctr1 = talloc_zero(ctx, struct srvsvc_NetShareCtr1);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr1);
+ if (ctr.ctr1 == NULL) {
+ goto nomem;
+ }
ctr.ctr1->count = alloc_entries;
ctr.ctr1->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo1, alloc_entries);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr1->array);
+ if (ctr.ctr1->array == NULL) {
+ goto nomem;
+ }
for (snum = 0; snum < num_services; snum++) {
if (allowed[snum] &&
case 2:
ctr.ctr2 = talloc_zero(ctx, struct srvsvc_NetShareCtr2);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr2);
+ if (ctr.ctr2 == NULL) {
+ goto nomem;
+ }
ctr.ctr2->count = alloc_entries;
ctr.ctr2->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo2, alloc_entries);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr2->array);
+ if (ctr.ctr2->array == NULL) {
+ goto nomem;
+ }
for (snum = 0; snum < num_services; snum++) {
if (allowed[snum] &&
case 501:
ctr.ctr501 = talloc_zero(ctx, struct srvsvc_NetShareCtr501);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr501);
+ if (ctr.ctr501 == NULL) {
+ goto nomem;
+ }
ctr.ctr501->count = alloc_entries;
ctr.ctr501->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo501, alloc_entries);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr501->array);
+ if (ctr.ctr501->array == NULL) {
+ goto nomem;
+ }
for (snum = 0; snum < num_services; snum++) {
if (allowed[snum] &&
case 502:
ctr.ctr502 = talloc_zero(ctx, struct srvsvc_NetShareCtr502);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr502);
+ if (ctr.ctr502 == NULL) {
+ goto nomem;
+ }
ctr.ctr502->count = alloc_entries;
ctr.ctr502->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo502, alloc_entries);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr502->array);
+ if (ctr.ctr502->array == NULL) {
+ goto nomem;
+ }
for (snum = 0; snum < num_services; snum++) {
if (allowed[snum] &&
case 1004:
ctr.ctr1004 = talloc_zero(ctx, struct srvsvc_NetShareCtr1004);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr1004);
+ if (ctr.ctr1004 == NULL) {
+ goto nomem;
+ }
ctr.ctr1004->count = alloc_entries;
ctr.ctr1004->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo1004, alloc_entries);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr1004->array);
+ if (ctr.ctr1004->array == NULL) {
+ goto nomem;
+ }
for (snum = 0; snum < num_services; snum++) {
if (allowed[snum] &&
case 1005:
ctr.ctr1005 = talloc_zero(ctx, struct srvsvc_NetShareCtr1005);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr1005);
+ if (ctr.ctr1005 == NULL) {
+ goto nomem;
+ }
ctr.ctr1005->count = alloc_entries;
ctr.ctr1005->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo1005, alloc_entries);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr1005->array);
+ if (ctr.ctr1005->array == NULL) {
+ goto nomem;
+ }
for (snum = 0; snum < num_services; snum++) {
if (allowed[snum] &&
case 1006:
ctr.ctr1006 = talloc_zero(ctx, struct srvsvc_NetShareCtr1006);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr1006);
+ if (ctr.ctr1006 == NULL) {
+ goto nomem;
+ }
ctr.ctr1006->count = alloc_entries;
ctr.ctr1006->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo1006, alloc_entries);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr1006->array);
+ if (ctr.ctr1006->array == NULL) {
+ goto nomem;
+ }
for (snum = 0; snum < num_services; snum++) {
if (allowed[snum] &&
case 1007:
ctr.ctr1007 = talloc_zero(ctx, struct srvsvc_NetShareCtr1007);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr1007);
+ if (ctr.ctr1007 == NULL) {
+ goto nomem;
+ }
ctr.ctr1007->count = alloc_entries;
ctr.ctr1007->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo1007, alloc_entries);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr1007->array);
+ if (ctr.ctr1007->array == NULL) {
+ goto nomem;
+ }
for (snum = 0; snum < num_services; snum++) {
if (allowed[snum] &&
case 1501:
ctr.ctr1501 = talloc_zero(ctx, struct srvsvc_NetShareCtr1501);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr1501);
+ if (ctr.ctr1501 == NULL) {
+ goto nomem;
+ }
ctr.ctr1501->count = alloc_entries;
ctr.ctr1501->array = talloc_zero_array(ctx, struct sec_desc_buf, alloc_entries);
- W_ERROR_HAVE_NO_MEMORY(ctr.ctr1501->array);
+ if (ctr.ctr1501->array == NULL) {
+ goto nomem;
+ }
for (snum = 0; snum < num_services; snum++) {
if (allowed[snum] &&
default:
DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n",
info_ctr->level));
- return WERR_INVALID_LEVEL;
+ ret = WERR_INVALID_LEVEL;
+ goto done;
}
*total_entries = alloc_entries;
}
info_ctr->ctr = ctr;
-
- return WERR_OK;
+ ret = WERR_OK;
+ goto done;
+nomem:
+ ret = WERR_NOT_ENOUGH_MEMORY;
+done:
+ return ret;
}
/*******************************************************************