public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nis/17913] New: NIS+ Stack allocation
@ 2015-02-01 20:14 max at cxib dot net
  2015-02-01 20:14 ` [Bug nis/17913] NIS+ getservbyname() " max at cxib dot net
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: max at cxib dot net @ 2015-02-01 20:14 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=17913

            Bug ID: 17913
           Summary: NIS+ Stack allocation
           Product: glibc
           Version: 2.20
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nis
          Assignee: unassigned at sourceware dot org
          Reporter: max at cxib dot net
                CC: kukuk at suse dot de

Reference: 
https://sourceware.org/bugzilla/show_bug.cgi?id=17897

Hi,

I've compared a _nss_nisplus_getservbyname_r() and _nss_nis_getservbyport_r()
and in NIS+ implementation, there is no limit for stack allocation like in NIS
implementation.


NIS 
-------------------------------------
enum nss_status
_nss_nis_getservbyport_r (int port, const char *protocol,
              struct servent *serv, char *buffer,
              size_t buflen, int *errnop)
{
  char *domain;
  if (__glibc_unlikely (yp_get_default_domain (&domain)))
    return NSS_STATUS_UNAVAIL;

  /* If the protocol is given, we only need one query.
     Otherwise try first port/tcp, then port/udp and then fallback
     to sequential scanning of services.byname.  */
  const char *proto = protocol != NULL ? protocol : "tcp";
  /* Limit protocol name length to the maximum size of an RPC packet.  */
  if (strlen (proto) > UDPMSGSIZE)  
<============================================
    {
      *errnop = ERANGE;
      return NSS_STATUS_UNAVAIL;
    }

  do
    {
      /* key is: "port/proto" */
      char key[sizeof (int) * 3 + strlen (proto) + 2];   <================ OK
      size_t keylen = snprintf (key, sizeof (key), "%d/%s", ntohs (port),
                proto);

-------------------------------------


NIS+
-------------------------------------
enum nss_status
_nss_nisplus_getservbyname_r (const char *name, const char *protocol,
                  struct servent *serv,
                  char *buffer, size_t buflen, int *errnop)
{
  if (tablename_val == NULL)
    {
      __libc_lock_lock (lock);

      enum nss_status status = _nss_create_tablename (errnop);

      __libc_lock_unlock (lock);

      if (status != NSS_STATUS_SUCCESS)
    return status;
    }

  if (name == NULL || protocol == NULL)
    {
      *errnop = EINVAL;
      return NSS_STATUS_NOTFOUND;
    }

  size_t protocol_len = strlen (protocol);
  char buf[strlen (name) + protocol_len + 17 + tablename_len]; <======= NOK
  int olderr = errno;
-------------------------------------

in one case, is checking the length, and the second is not.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-08-24  9:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-01 20:14 [Bug nis/17913] New: NIS+ Stack allocation max at cxib dot net
2015-02-01 20:14 ` [Bug nis/17913] NIS+ getservbyname() " max at cxib dot net
2015-02-18 13:32 ` fweimer at redhat dot com
2015-08-24  3:41 ` ppluzhnikov at google dot com
2015-08-24  3:55 ` ppluzhnikov at google dot com
2015-08-24  9:24 ` max at cxib dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).