get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/810281/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 810281,
    "url": "http://patchwork.ozlabs.org/api/patches/810281/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/glibc/patch/1504643122-14874-6-git-send-email-adhemerval.zanella@linaro.org/",
    "project": {
        "id": 41,
        "url": "http://patchwork.ozlabs.org/api/projects/41/?format=api",
        "name": "GNU C Library",
        "link_name": "glibc",
        "list_id": "libc-alpha.sourceware.org",
        "list_email": "libc-alpha@sourceware.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<1504643122-14874-6-git-send-email-adhemerval.zanella@linaro.org>",
    "list_archive_url": null,
    "date": "2017-09-05T20:25:18",
    "name": "[5/9] posix: Fix getpwnam_r usage (BZ #1062)",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "ca8585b74a81599f2772150a1a8901a78f2349e2",
    "submitter": {
        "id": 66065,
        "url": "http://patchwork.ozlabs.org/api/people/66065/?format=api",
        "name": "Adhemerval Zanella",
        "email": "adhemerval.zanella@linaro.org"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/glibc/patch/1504643122-14874-6-git-send-email-adhemerval.zanella@linaro.org/mbox/",
    "series": [
        {
            "id": 1647,
            "url": "http://patchwork.ozlabs.org/api/series/1647/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/glibc/list/?series=1647",
            "date": "2017-09-05T20:25:13",
            "name": "posix: glob fixes and refactor",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/1647/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/810281/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/810281/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<libc-alpha-return-84212-incoming=patchwork.ozlabs.org@sourceware.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "mailing list libc-alpha@sourceware.org"
        ],
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=sourceware.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=libc-alpha-return-84212-incoming=patchwork.ozlabs.org@sourceware.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org; dkim=pass (1024-bit key;\n\tsecure) header.d=sourceware.org header.i=@sourceware.org\n\theader.b=\"HSI3nq84\"; dkim-atps=neutral",
            "sourceware.org; auth=none"
        ],
        "Received": [
            "from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xmytL6B4zz9sPs\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed,  6 Sep 2017 06:26:50 +1000 (AEST)",
            "(qmail 49483 invoked by alias); 5 Sep 2017 20:25:54 -0000",
            "(qmail 48835 invoked by uid 89); 5 Sep 2017 20:25:49 -0000"
        ],
        "DomainKey-Signature": "a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:cc:subject:date:message-id:in-reply-to\n\t:references; q=dns; s=default; b=Wc77E7R7DthmVTm9VboVQYQtU4UQujG\n\ts0Wh0ny+umIMGFgfdwc+4M9KSF5fCAK/IFgiVLeWVxtRpnFtlGIzo+8oPf/UKEf8\n\tP18fuBAwx1BrGTLlldo9VaifrYJJH/bpWCSuS8soKgyYu3dPdAJnKbrS6BUfIthj\n\t8H2O9dsFjoAs=",
        "DKIM-Signature": "v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:cc:subject:date:message-id:in-reply-to\n\t:references; s=default; bh=ugzsZmLO86wRXxXbmWjH9WRq9EA=; b=HSI3n\n\tq84s3bNofahB1zBfLwPhxi1+NI4UgMSThUHpgU3C31xz5vNPGnncc9AqT503vsuO\n\tSrK3Kxl7Sf3jiR/z/4vmQ54JZ7oz/MTVfn6fwEU9KTjD2614AN3tmpbwtdDtsLnV\n\t/eyF+pY05XMlqgn3Cnu7cKRq8p2zoh4+ZYRZMQ=",
        "Mailing-List": "contact libc-alpha-help@sourceware.org; run by ezmlm",
        "Precedence": "bulk",
        "List-Id": "<libc-alpha.sourceware.org>",
        "List-Unsubscribe": "<mailto:libc-alpha-unsubscribe-incoming=patchwork.ozlabs.org@sourceware.org>",
        "List-Subscribe": "<mailto:libc-alpha-subscribe@sourceware.org>",
        "List-Archive": "<http://sourceware.org/ml/libc-alpha/>",
        "List-Post": "<mailto:libc-alpha@sourceware.org>",
        "List-Help": "<mailto:libc-alpha-help@sourceware.org>,\n\t<http://sourceware.org/ml/#faqs>",
        "Sender": "libc-alpha-owner@sourceware.org",
        "X-Virus-Found": "No",
        "X-Spam-SWARE-Status": "No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=lacking",
        "X-HELO": "mail-qk0-f169.google.com",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=Blvulj+f48B14LwO6vJPYfxom6ZpkU8t9dDAAMQv7GU=;\n\tb=fDSqlKXFgrzZ2SQAyBX8sV7T2S5slA83sq9SP4//wLL227xLUasxNH+V0I4885Eclj\n\ty+BrgqOhwfgh+gyoqg2/GCKGv7QYgum5lQB+m5QzASknLJBRiiW5C0APTpCJkHcuoau8\n\tgB55X4cK6Nt/mP81eLLog+C5xGvTINhn6lSNTWvbeWr1VkMnRmjK0f+rGzsZUCYQNwPw\n\tQRAoe6ScIUcLHdQ3h2E5KuXpMY6CQzktbIcHh3BYPrDN7FavYpPmjvci6ho7GIzEFQgf\n\tmehFKUsDsZhCzJu++NBDnDFnKQdmmbMi6DU+qFQLEpRXsamzQ8ES1Fg0jQVmb6KeZX3i\n\trFbg==",
        "X-Gm-Message-State": "AHPjjUgd7uoCSwYlAu18uYCFUTBZBCOsivHEscQFYFhmuaBU2mgIzzfo\n\tcCE//VcL5NTiX400JfBNGA==",
        "X-Google-Smtp-Source": "ADKCNb7UK1hbNrfLf1Vphvq8IlWY/RDOXlSCq6dfo4PdNDrqBUrYgD9amna9jF77wlte53QJwNuNHQ==",
        "X-Received": "by 10.55.86.134 with SMTP id k128mr501528qkb.56.1504643140870;\n\tTue, 05 Sep 2017 13:25:40 -0700 (PDT)",
        "From": "Adhemerval Zanella <adhemerval.zanella@linaro.org>",
        "To": "libc-alpha@sourceware.org",
        "Cc": "Paul Eggert <eggert@cs.ucla.edu>",
        "Subject": "[PATCH 5/9] posix: Fix getpwnam_r usage (BZ #1062)",
        "Date": "Tue,  5 Sep 2017 17:25:18 -0300",
        "Message-Id": "<1504643122-14874-6-git-send-email-adhemerval.zanella@linaro.org>",
        "In-Reply-To": "<1504643122-14874-1-git-send-email-adhemerval.zanella@linaro.org>",
        "References": "<1504643122-14874-1-git-send-email-adhemerval.zanella@linaro.org>"
    },
    "content": "This patch fixes longstanding misuse of errno after getpwnam_r,\nwhich returns an error number rather than setting errno.  This is\nsync with gnulib commit 5db9301.\n\nChecked on x86_64-linux-gnu and on a build using build-many-glibcs.py\nfor all major architectures.\n\n\t[BZ #1062]\n\t* posix/glob.c (glob): Port recent patches to platforms\n\tlacking getpwnam_r.\n\t(glob): Fix longstanding misuse of errno after getpwnam_r, which\n\treturns an error number rather than setting errno.\n---\n ChangeLog    |   6 +++\n posix/glob.c | 164 +++++++++--------------------------------------------------\n 2 files changed, 30 insertions(+), 140 deletions(-)",
    "diff": "diff --git a/posix/glob.c b/posix/glob.c\nindex 15c6295..340cf08 100644\n--- a/posix/glob.c\n+++ b/posix/glob.c\n@@ -15,10 +15,6 @@\n    License along with the GNU C Library; if not, see\n    <http://www.gnu.org/licenses/>.  */\n \n-#ifndef _LIBC\n-# include <config.h>\n-#endif\n-\n #include <glob.h>\n \n #include <errno.h>\n@@ -39,10 +35,6 @@\n #endif\n \n #include <errno.h>\n-#ifndef __set_errno\n-# define __set_errno(val) errno = (val)\n-#endif\n-\n #include <dirent.h>\n #include <stdlib.h>\n #include <string.h>\n@@ -82,12 +74,8 @@\n \n #include <flexmember.h>\n #include <glob_internal.h>\n+#include <scratch_buffer.h>\n \n-#ifdef _SC_GETPW_R_SIZE_MAX\n-# define GETPW_R_SIZE_MAX()\tsysconf (_SC_GETPW_R_SIZE_MAX)\n-#else\n-# define GETPW_R_SIZE_MAX()\t(-1)\n-#endif\n #ifdef _SC_LOGIN_NAME_MAX\n # define GET_LOGIN_NAME_MAX()\tsysconf (_SC_LOGIN_NAME_MAX)\n #else\n@@ -649,97 +637,36 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),\n \t      if (success)\n \t\t{\n \t\t  struct passwd *p;\n-\t\t  char *malloc_pwtmpbuf = NULL;\n-\t\t  char *pwtmpbuf;\n+\t\t  struct scratch_buffer pwtmpbuf;\n+\t\t  scratch_buffer_init (&pwtmpbuf);\n # if defined HAVE_GETPWNAM_R || defined _LIBC\n-\t\t  long int pwbuflenmax = GETPW_R_SIZE_MAX ();\n-\t\t  size_t pwbuflen = pwbuflenmax;\n \t\t  struct passwd pwbuf;\n-\t\t  int save = errno;\n \n-#  ifndef _LIBC\n-\t\t  if (! (0 < pwbuflenmax && pwbuflenmax <= SIZE_MAX))\n-\t\t    /* 'sysconf' does not support _SC_GETPW_R_SIZE_MAX.\n-\t\t       Try a moderate value.  */\n-\t\t    pwbuflen = 1024;\n-#  endif\n-\t\t  if (glob_use_alloca (alloca_used, pwbuflen))\n-\t\t    pwtmpbuf = alloca_account (pwbuflen, alloca_used);\n-\t\t  else\n+\t\t  while (getpwnam_r (name, &pwbuf,\n+\t\t\t\t     pwtmpbuf.data, pwtmpbuf.length, &p)\n+\t\t\t == ERANGE)\n \t\t    {\n-\t\t      pwtmpbuf = malloc (pwbuflen);\n-\t\t      if (pwtmpbuf == NULL)\n+\t\t      if (!scratch_buffer_grow (&pwtmpbuf))\n \t\t\t{\n-\t\t\t  if (__glibc_unlikely (malloc_name))\n-\t\t\t    free (name);\n \t\t\t  retval = GLOB_NOSPACE;\n \t\t\t  goto out;\n \t\t\t}\n-\t\t      malloc_pwtmpbuf = pwtmpbuf;\n-\t\t    }\n-\n-\t\t  while (getpwnam_r (name, &pwbuf, pwtmpbuf, pwbuflen, &p)\n-\t\t\t != 0)\n-\t\t    {\n-\t\t      size_t newlen;\n-\t\t      bool v;\n-\t\t      if (errno != ERANGE)\n-\t\t\t{\n-\t\t\t  p = NULL;\n-\t\t\t  break;\n-\t\t\t}\n-\t\t      v = size_add_wrapv (pwbuflen, pwbuflen, &newlen);\n-\t\t      if (!v && malloc_pwtmpbuf == NULL\n-\t\t\t  && glob_use_alloca (alloca_used, newlen))\n-\t\t\tpwtmpbuf = extend_alloca_account (pwtmpbuf, pwbuflen,\n-\t\t\t\t\t\t\t  newlen, alloca_used);\n-\t\t      else\n-\t\t\t{\n-\t\t\t  char *newp = (v ? NULL\n-\t\t\t\t\t: realloc (malloc_pwtmpbuf, newlen));\n-\t\t\t  if (newp == NULL)\n-\t\t\t    {\n-\t\t\t      free (malloc_pwtmpbuf);\n-\t\t\t      if (__glibc_unlikely (malloc_name))\n-\t\t\t\tfree (name);\n-\t\t\t      retval = GLOB_NOSPACE;\n-\t\t\t      goto out;\n-\t\t\t    }\n-\t\t\t  malloc_pwtmpbuf = pwtmpbuf = newp;\n-\t\t\t}\n-\t\t      pwbuflen = newlen;\n-\t\t      __set_errno (save);\n \t\t    }\n # else\n \t\t  p = getpwnam (name);\n # endif\n-\t\t  if (__glibc_unlikely (malloc_name))\n-\t\t    free (name);\n \t\t  if (p != NULL)\n \t\t    {\n-\t\t      if (malloc_pwtmpbuf == NULL)\n-\t\t\thome_dir = p->pw_dir;\n-\t\t      else\n+\t\t      home_dir = strdup (p->pw_dir);\n+\t\t      malloc_home_dir = 1;\n+\t\t      if (home_dir == NULL)\n \t\t\t{\n-\t\t\t  size_t home_dir_len = strlen (p->pw_dir) + 1;\n-\t\t\t  if (glob_use_alloca (alloca_used, home_dir_len))\n-\t\t\t    home_dir = alloca_account (home_dir_len,\n-\t\t\t\t\t\t       alloca_used);\n-\t\t\t  else\n-\t\t\t    {\n-\t\t\t      home_dir = malloc (home_dir_len);\n-\t\t\t      if (home_dir == NULL)\n-\t\t\t\t{\n-\t\t\t\t  free (pwtmpbuf);\n-\t\t\t\t  retval = GLOB_NOSPACE;\n-\t\t\t\t  goto out;\n-\t\t\t\t}\n-\t\t\t      malloc_home_dir = 1;\n-\t\t\t    }\n-\t\t\t  memcpy (home_dir, p->pw_dir, home_dir_len);\n+\t\t\t  scratch_buffer_free (&pwtmpbuf);\n+\t\t\t  retval = GLOB_NOSPACE;\n+\t\t\t  goto out;\n \t\t\t}\n \t\t    }\n-\t\t  free (malloc_pwtmpbuf);\n+\t\t  scratch_buffer_free (&pwtmpbuf);\n \t\t}\n \t      else\n \t\t{\n@@ -876,61 +803,21 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),\n \t  /* Look up specific user's home directory.  */\n \t  {\n \t    struct passwd *p;\n-\t    char *malloc_pwtmpbuf = NULL;\n+\t    struct scratch_buffer pwtmpbuf;\n+\t    scratch_buffer_init (&pwtmpbuf);\n+\n #  if defined HAVE_GETPWNAM_R || defined _LIBC\n-\t    long int buflenmax = GETPW_R_SIZE_MAX ();\n-\t    size_t buflen = buflenmax;\n-\t    char *pwtmpbuf;\n \t    struct passwd pwbuf;\n-\t    int save = errno;\n-\n-#   ifndef _LIBC\n-\t    if (! (0 <= buflenmax && buflenmax <= SIZE_MAX))\n-\t      /* Perhaps 'sysconf' does not support _SC_GETPW_R_SIZE_MAX.  Try a\n-\t\t moderate value.  */\n-\t      buflen = 1024;\n-#   endif\n-\t    if (glob_use_alloca (alloca_used, buflen))\n-\t      pwtmpbuf = alloca_account (buflen, alloca_used);\n-\t    else\n+\n+\t    while (getpwnam_r (user_name, &pwbuf,\n+\t\t\t       pwtmpbuf.data, pwtmpbuf.length, &p)\n+\t\t   == ERANGE)\n \t      {\n-\t\tpwtmpbuf = malloc (buflen);\n-\t\tif (pwtmpbuf == NULL)\n+\t\tif (!scratch_buffer_grow (&pwtmpbuf))\n \t\t  {\n-\t\t  nomem_getpw:\n-\t\t    if (__glibc_unlikely (malloc_user_name))\n-\t\t      free (user_name);\n \t\t    retval = GLOB_NOSPACE;\n \t\t    goto out;\n \t\t  }\n-\t\tmalloc_pwtmpbuf = pwtmpbuf;\n-\t      }\n-\n-\t    while (getpwnam_r (user_name, &pwbuf, pwtmpbuf, buflen, &p) != 0)\n-\t      {\n-\t\tsize_t newlen;\n-\t\tbool v;\n-\t\tif (errno != ERANGE)\n-\t\t  {\n-\t\t    p = NULL;\n-\t\t    break;\n-\t\t  }\n-\t\tv = size_add_wrapv (buflen, buflen, &newlen);\n-\t\tif (!v && malloc_pwtmpbuf == NULL\n-\t\t    && glob_use_alloca (alloca_used, newlen))\n-\t\t  pwtmpbuf = extend_alloca_account (pwtmpbuf, buflen,\n-\t\t\t\t\t\t    newlen, alloca_used);\n-\t\telse\n-\t\t  {\n-\t\t    char *newp = v ? NULL : realloc (malloc_pwtmpbuf, newlen);\n-\t\t    if (newp == NULL)\n-\t\t      {\n-\t\t\tfree (malloc_pwtmpbuf);\n-\t\t\tgoto nomem_getpw;\n-\t\t      }\n-\t\t    malloc_pwtmpbuf = pwtmpbuf = newp;\n-\t\t  }\n-\t\t__set_errno (save);\n \t      }\n #  else\n \t    p = getpwnam (user_name);\n@@ -957,7 +844,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),\n \t\t    dirname = malloc (home_len + rest_len + 1);\n \t\t    if (dirname == NULL)\n \t\t      {\n-\t\t\tfree (malloc_pwtmpbuf);\n+\t\t\tscratch_buffer_free (&pwtmpbuf);\n \t\t\tretval = GLOB_NOSPACE;\n \t\t\tgoto out;\n \t\t      }\n@@ -968,13 +855,9 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),\n \n \t\tdirlen = home_len + rest_len;\n \t\tdirname_modified = 1;\n-\n-\t\tfree (malloc_pwtmpbuf);\n \t      }\n \t    else\n \t      {\n-\t\tfree (malloc_pwtmpbuf);\n-\n \t\tif (flags & GLOB_TILDE_CHECK)\n \t\t  {\n \t\t    /* We have to regard it as an error if we cannot find the\n@@ -983,6 +866,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),\n \t\t    goto out;\n \t\t  }\n \t      }\n+\t    scratch_buffer_free (&pwtmpbuf);\n \t  }\n #endif /* !WINDOWS32 */\n \t}\n",
    "prefixes": [
        "5/9"
    ]
}