/* Copyright (c) 1997-2025 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <assert.h>
#include <string.h>
#include <rpcsvc/nis.h>
#include <libc-diag.h>
#include <shlib-compat.h>
#include "nis_xdr.h"
#include "nis_intern.h"
#include "libnsl.h"
struct ib_request *
__create_ib_request (const_nis_name name, unsigned int flags)
{
struct ib_request *ibreq = calloc (1, sizeof (struct ib_request));
nis_attr *search_val = NULL;
size_t search_len = 0;
size_t size = 0;
if (ibreq == NULL)
return NULL;
ibreq->ibr_flags = flags;
char *cptr = strdupa (name);
/* Not of "[key=value,key=value,...],foo.." format? */
if (cptr[0] != '[')
{
ibreq->ibr_name = strdup (cptr);
if (ibreq->ibr_name == NULL)
{
free (ibreq);
return NULL;
}
return ibreq;
}
/* "[key=value,...],foo" format */
ibreq->ibr_name = strchr (cptr, ']');
if (ibreq->ibr_name == NULL || ibreq->ibr_name[1] != ',')
{
/* The object has not really been built yet so we use free. */
free (ibreq);
return NULL;
}
/* Check if we have an entry of "[key=value,],bar". If, remove the "," */
if (ibreq->ibr_name[-1] == ',')
ibreq->ibr_name[-1] = '\0';
else
ibreq->ibr_name[0] = '\0';
ibreq->ibr_name += 2;
ibreq->ibr_name = strdup (ibreq->ibr_name);
if (ibreq->ibr_name == NULL)
{
free_null<