openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/nss-pam-ldapd/0.9.8-r0/nss-pam-ldapd-0.9.8/nss/group.c
static nss_status_t read_gids(TFILE* fp, gid_t skipgroup, long int* start,
                              long int* size, gid_t** groupsp, long int limit,
                              int* errnop)
{
    int32_t res = (int32_t)NSLCD_RESULT_BEGIN;
    int32_t tmpint32, tmp2int32, tmp3int32;
    gid_t gid;
#ifdef NSS_FLAVOUR_GLIBC
    gid_t* newgroups;
    long int newsize;
#endif /* NSS_FLAVOUR_GLIBC */
    /* loop over results */
    while (res == (int32_t)NSLCD_RESULT_BEGIN)
    {
        /* skip group name */
        SKIP_STRING(fp);
        /* skip passwd entry */
        SKIP_STRING(fp);
        /* read gid */
        READ_INT32(fp, gid);
        /* skip members */
        SKIP_STRINGLIST(fp);
        /* only add the group to the list if it is not the specified group */
        if (gid != skipgroup)
        {
#ifdef NSS_FLAVOUR_GLIBC
            /* check if we reached the limit */
            if ((limit > 0) && (*start >= limit))
                return NSS_STATUS_TRYAGAIN;
            /* check if our buffer is large enough */
            if ((*start) >= (*size))
            {
                /* for some reason Glibc expects us to grow the array
                   (completely different from all other NSS functions) */
                /* calculate new size */
                newsize = 2 * (*size);
                if ((limit > 0) && (*start >= limit))
                    newsize = limit;
                /* allocate new memory */
                newgroups = realloc(*groupsp, newsize * sizeof(gid_t));
                if (newgroups == NULL)
                    return NSS_STATUS_TRYAGAIN;
                *groupsp = newgroups;
                *size = newsize;
            }
#endif /* NSS_FLAVOUR_GLIBC */
#ifdef NSS_FLAVOUR_SOLARIS
            /* check if we reached the limit */
            if ((limit > 0) && (*start >= limit))
            {
                *errnop = 1; /* this is args->erange */
                return NSS_STATUS_NOTFOUND;
            }
#endif /* NSS_FLAVOUR_SOLARIS */
            /* add gid to list */
            (*groupsp)[(*start)++] = gid;
        }
        /* read next response code (don't bail out on not success since we
           just want to build up a list) */
        READ_INT32(fp, res);
    }
    /* return the proper status code */
    return NSS_STATUS_SUCCESS;
}
/* read all group entries from the stream and add
   gids of these groups to the list */
read all group entries from the stream and add
gids of these groups to the list
read all group entries from the stream and add gids of these groups to the list
static nss_status_t read_gids(TFILE* fp, gid_t skipgroup, long int* start,
                              long int* size, gid_t** groupsp, long int limit,
                              int* errnop)
{
    int32_t res = (int32_t)NSLCD_RESULT_BEGIN;
    int32_t tmpint32, tmp2int32, tmp3int32;
    gid_t gid;
#ifdef NSS_FLAVOUR_GLIBC
    gid_t* newgroups;
    long int newsize;
#endif 
    while (res == (int32_t)NSLCD_RESULT_BEGIN)
    {
        SKIP_STRING(fp);
        SKIP_STRING(fp);
        READ_INT32(fp, gid);
        SKIP_STRINGLIST(fp);
        if (gid != skipgroup)
        {
#ifdef NSS_FLAVOUR_GLIBC
            if ((limit > 0) && (*start >= limit))
                return NSS_STATUS_TRYAGAIN;
            if ((*start) >= (*size))
            {
                newsize = 2 * (*size);
                if ((limit > 0) && (*start >= limit))
                    newsize = limit;
                newgroups = realloc(*groupsp, newsize * sizeof(gid_t));
                if (newgroups == NULL)
                    return NSS_STATUS_TRYAGAIN;
                *groupsp = newgroups;
                *size = newsize;
            }
#endif 
#ifdef NSS_FLAVOUR_SOLARIS
            if ((limit > 0) && (*start >= limit))
            {
                *errnop = 1; 
                return NSS_STATUS_NOTFOUND;
            }
#endif 
            (*groupsp)[(*start)++] = gid;
        }
        READ_INT32(fp, res);
    }
    return NSS_STATUS_SUCCESS;
}
static nss_status_t read_gids ( TFILE * fp , gid_t skipgroup , long int * start , long int * size , gid_t * * groupsp , long int limit , int * errnop ) { int32_t res = ( int32_t ) NSLCD_RESULT_BEGIN ; int32_t tmpint32 , tmp2int32 , tmp3int32 ; gid_t gid ; #ifdef NSS_FLAVOUR_GLIBC gid_t * newgroups ; long int newsize ; #endif while ( res == ( int32_t ) NSLCD_RESULT_BEGIN ) { SKIP_STRING ( fp ) ; SKIP_STRING ( fp ) ; READ_INT32 ( fp , gid ) ; SKIP_STRINGLIST ( fp ) ; if ( gid != skipgroup ) { #ifdef NSS_FLAVOUR_GLIBC if ( ( limit > 0 ) && ( * start >= limit ) ) return NSS_STATUS_TRYAGAIN ; if ( ( * start ) >= ( * size ) ) { newsize = 2 * ( * size ) ; if ( ( limit > 0 ) && ( * start >= limit ) ) newsize = limit ; newgroups = realloc ( * groupsp , newsize * sizeof ( gid_t ) ) ; if ( newgroups == NULL ) return NSS_STATUS_TRYAGAIN ; * groupsp = newgroups ; * size = newsize ; } #endif #ifdef NSS_FLAVOUR_SOLARIS if ( ( limit > 0 ) && ( * start >= limit ) ) { * errnop = 1 ; return NSS_STATUS_NOTFOUND ; } #endif ( * groupsp ) [ ( * start ) ++ ] = gid ; } READ_INT32 ( fp , res ) ; } return NSS_STATUS_SUCCESS ; }
read all group entries from the stream and add
gids of these groups to the list
read all group entries from the stream and add gids of these groups to the list
/* NSS_FLAVOUR_GLIBC */ /* loop over results */ /* skip group name */ /* skip passwd entry */ /* read gid */ /* skip members */ /* only add the group to the list if it is not the specified group */ /* check if we reached the limit */ /* check if our buffer is large enough */ /* for some reason Glibc expects us to grow the array
                   (completely different from all other NSS functions) */ /* calculate new size */ /* allocate new memory */ /* NSS_FLAVOUR_GLIBC */ /* check if we reached the limit */ /* this is args->erange */ /* NSS_FLAVOUR_SOLARIS */ /* add gid to list */ /* read next response code (don't bail out on not success since we
           just want to build up a list) */ /* return the proper status code */