Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/814582/?format=api
{ "id": 814582, "url": "http://patchwork.ozlabs.org/api/patches/814582/?format=api", "web_url": "http://patchwork.ozlabs.org/project/lede/patch/20170917040532.3926-1-maxim.gorbachyov@gmail.com/", "project": { "id": 54, "url": "http://patchwork.ozlabs.org/api/projects/54/?format=api", "name": "LEDE development", "link_name": "lede", "list_id": "lede-dev.lists.infradead.org", "list_email": "lede-dev@lists.infradead.org", "web_url": "http://lede-project.org/", "scm_url": "", "webscm_url": "http://git.lede-project.org/", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170917040532.3926-1-maxim.gorbachyov@gmail.com>", "list_archive_url": null, "date": "2017-09-17T04:05:32", "name": "[LEDE-DEV] uci/file: replace mktemp() with mkstemp()", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "8886b87e2f64303e09f9026e91fa23fbc144b2c8", "submitter": { "id": 72380, "url": "http://patchwork.ozlabs.org/api/people/72380/?format=api", "name": "Maxim Gorbachyov", "email": "maxim.gorbachyov@gmail.com" }, "delegate": { "id": 54613, "url": "http://patchwork.ozlabs.org/api/users/54613/?format=api", "username": "blogic", "first_name": "John", "last_name": "Crispin", "email": "blogic@openwrt.org" }, "mbox": "http://patchwork.ozlabs.org/project/lede/patch/20170917040532.3926-1-maxim.gorbachyov@gmail.com/mbox/", "series": [ { "id": 3481, "url": "http://patchwork.ozlabs.org/api/series/3481/?format=api", "web_url": "http://patchwork.ozlabs.org/project/lede/list/?series=3481", "date": "2017-09-17T04:05:32", "name": "[LEDE-DEV] uci/file: replace mktemp() with mkstemp()", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/3481/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/814582/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/814582/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org; spf=none (mailfrom)\n\tsmtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133;\n\thelo=bombadil.infradead.org;\n\tenvelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"gk5VzcMX\"; \n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"S78Kcj1e\"; dkim-atps=neutral" ], "Received": [ "from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\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 3xvwZD3Ww9z9sBZ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 17 Sep 2017 14:07:00 +1000 (AEST)", "from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dtQqq-0008I4-9y; Sun, 17 Sep 2017 04:06:36 +0000", "from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dtQqM-0008Bh-Ca\n\tfor lede-dev@lists.infradead.org; Sun, 17 Sep 2017 04:06:12 +0000", "by mail-oi0-x243.google.com with SMTP id v66so1718896oig.1\n\tfor <lede-dev@lists.infradead.org>;\n\tSat, 16 Sep 2017 21:05:42 -0700 (PDT)", "from localhost.localdomain\n\t(108-197-236-208.lightspeed.sntcca.sbcglobal.net. [108.197.236.208])\n\tby smtp.gmail.com with ESMTPSA id\n\te8sm6655878oic.7.2017.09.16.21.05.40\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSat, 16 Sep 2017 21:05:41 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe:\n\tList-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Message-Id:\n\tDate:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:\n\tResent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:\n\tList-Owner; bh=Q/sRX9QIiCHB8ghkawRLHMf8xzDCPFf4Pr2blMIX5Fk=;\n\tb=gk5VzcMXQHWfdD\n\tu/wjKzf8O6bl7NW1If/e4+vitJYVX2Oj01jzsFfky4Wq/b0O1UnKmeiSeOjxGADG+m65paWUEN5Xm\n\tlnXB3oPE/2ALx25G9C5mHtqNXhNHRN0W2AoKK9k9cGKrnpx47H32M6Li1fhEvKRWuj1N73Zo7oh1U\n\tfi+6p9QLjjjK0/fbmfxvQDzGdTa3/D0G/y530qk2okLo5KNgDAXNhLMR7wsWu45bmUvVq26HIXlwr\n\txHRFUmOuOaI96c00EnRdFoMtIVY9t+1m406mmffEHurQzSvptOhOeSJJEdEd5ofw8E5Yd2KJGOMQj\n\t6xkRSROdntXLvQfvjivQ==;", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id;\n\tbh=F9DCt/Fz+ay6Rj4/ETYnyAS+cSsPTdc1uLSxfrbNa+E=;\n\tb=S78Kcj1egsbcPxepo3uXchRsdBeqEQlEZV4PYLanVbmPFKAyzBcTGZueWauAH9Qw+v\n\t9ePYqcsZGRiO1m+UmJZxKBhSEsX3Yr80+SOGPrnkR3YUER+INyO9ikErzBAUVFNj/mVA\n\tRBo1JP/oat3fXCCNPomv+gzAdQDHgWJBWijcejGICZ3CgceVI0hkKrQlvrIoNc1tlt8v\n\tfbNybM/lkgWaWilQ0JnupGqxHIULGDVt6CcXHhbPrOclvYtRTT4RQoKunG05qPQSYS3g\n\tL35GAVjomJdW0rU5lf15mnCdgGtoGQ3BXDJt/1A+eevLwGoFl4gcNXlYZzehrQZlPJ8V\n\tFGlg==" ], "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;\n\tbh=F9DCt/Fz+ay6Rj4/ETYnyAS+cSsPTdc1uLSxfrbNa+E=;\n\tb=YzvlVRE+Mysoi/tCX7lkpJOqGoLZytwu3AX2mX3lj5KoPHY8xrLJe4BIiIB5u58s7x\n\twgLwP5iuqf3uA7arPNFb6dTSoXNUQq7bd1nST34o7/1YmbUD4xmJ63VlS7N0VY2golyx\n\t1Cvl2YD1zlp6/6W70hZalczMQr5hf6p/ywPuMKv/4WmQbUTHQPydTP4uqeD2gRHe0EFp\n\tMXGo4Kqeyv28GJxwi8Zb18L/VTUFCYeSxvg5mJQHCIicKTKTdKWXs95Kz2OBmxiPfp/p\n\tZPNlTpIy2bYkaGqT2WY+wqMrjBOy9zqEOrh2cX5n/iI8siSap+OIHae0Mdn6G99ysf1T\n\tkQRg==", "X-Gm-Message-State": "AHPjjUhIFIGjGVEFavbuhCUnbOlETpSr10rDMoXW5+mkbYzIfL8DKihC\n\tz24wJtq+e9QuNGYxF34=", "X-Google-Smtp-Source": "AOwi7QDS1M9sWFNJWT1VzuDuAZl5D8Tp/jQv946fSTRKqC4qcdf6bh/SKVu8GVvNwMdjvoCj983LvA==", "X-Received": "by 10.202.168.140 with SMTP id\n\tr134mr30076599oie.232.1505621142021; \n\tSat, 16 Sep 2017 21:05:42 -0700 (PDT)", "From": "Maxim Gorbachyov <maxim.gorbachyov@gmail.com>", "To": "lede-dev@lists.infradead.org", "Date": "Sat, 16 Sep 2017 21:05:32 -0700", "Message-Id": "<20170917040532.3926-1-maxim.gorbachyov@gmail.com>", "X-Mailer": "git-send-email 2.14.1", "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ", "X-CRM114-CacheID": "sfid-20170916_210607_077364_5B9A0562 ", "X-CRM114-Status": "GOOD ( 10.63 )", "X-Spam-Score": "-2.0 (--)", "X-Spam-Report": "SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details: (-2.0 points)\n\tpts rule name description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/,\n\tno\n\ttrust [2607:f8b0:4003:c06:0:0:0:243 listed in] [list.dnswl.org]\n\t-0.0 SPF_PASS SPF: sender matches SPF record\n\t0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\n\tprovider (maxim.gorbachyov[at]gmail.com)\n\t-1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain", "Subject": "[LEDE-DEV] [PATCH] uci/file: replace mktemp() with mkstemp()", "X-BeenThere": "lede-dev@lists.infradead.org", "X-Mailman-Version": "2.1.21", "Precedence": "list", "List-Id": "<lede-dev.lists.infradead.org>", "List-Unsubscribe": "<http://lists.infradead.org/mailman/options/lede-dev>,\n\t<mailto:lede-dev-request@lists.infradead.org?subject=unsubscribe>", "List-Archive": "<http://lists.infradead.org/pipermail/lede-dev/>", "List-Post": "<mailto:lede-dev@lists.infradead.org>", "List-Help": "<mailto:lede-dev-request@lists.infradead.org?subject=help>", "List-Subscribe": "<http://lists.infradead.org/mailman/listinfo/lede-dev>,\n\t<mailto:lede-dev-request@lists.infradead.org?subject=subscribe>", "Cc": "Maxim Gorbachyov <maxim.gorbachyov@gmail.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Sender": "\"Lede-dev\" <lede-dev-bounces@lists.infradead.org>", "Errors-To": "lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org" }, "content": "Because mktemp() is evil.\n\nSigned-off-by: Maxim Gorbachyov <maxim.gorbachyov@gmail.com>\n---\n file.c | 19 +++++++++++--------\n 1 file changed, 11 insertions(+), 8 deletions(-)", "diff": "diff --git a/file.c b/file.c\nindex 494c649..ad0355b 100644\n--- a/file.c\n+++ b/file.c\n@@ -28,6 +28,7 @@\n #include <glob.h>\n #include <string.h>\n #include <stdlib.h>\n+#include <errno.h>\n \n #include \"uci.h\"\n #include \"uci_internal.h\"\n@@ -725,8 +726,8 @@ static void uci_file_commit(struct uci_context *ctx, struct uci_package **packag\n \tchar *name = NULL;\n \tchar *path = NULL;\n \tchar *filename = NULL;\n-\tstruct stat statbuf;\n \tbool do_rename = false;\n+\tint fd;\n \n \tif (!p->path) {\n \t\tif (overwrite)\n@@ -772,18 +773,20 @@ static void uci_file_commit(struct uci_context *ctx, struct uci_package **packag\n \t\t\tgoto done;\n \t}\n \n-\tif (!mktemp(filename))\n-\t\t*filename = 0;\n+\tfd = mkstemp(filename);\n+\tif (fd == -1)\n+\t\tUCI_THROW(ctx, UCI_ERR_IO);\n \n-\tif (!*filename) {\n-\t\tfree(filename);\n+\tif ((flock(fd, LOCK_EX) < 0) && (errno != ENOSYS))\n+\t\tUCI_THROW(ctx, UCI_ERR_IO);\n+\n+\tif (lseek(fd, 0, SEEK_SET) < 0)\n \t\tUCI_THROW(ctx, UCI_ERR_IO);\n-\t}\n \n-\tif ((stat(filename, &statbuf) == 0) && ((statbuf.st_mode & S_IFMT) != S_IFREG))\n+\tf2 = fdopen(fd, \"w+\");\n+\tif (!f2)\n \t\tUCI_THROW(ctx, UCI_ERR_IO);\n \n-\tf2 = uci_open_stream(ctx, filename, p->path, SEEK_SET, true, true);\n \tuci_export(ctx, f2, p, false);\n \n \tfflush(f2);\n", "prefixes": [ "LEDE-DEV" ] }