public inbox for cygwin-apps-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-apps-cvs@sourceware.org Subject: [cygrunsrv - a wrapper for unix daemons to make them controllable as windows services] branch master, updated. 405add89a98ee2c995c38dbbc47c8b95a2d721d8 Date: Mon, 6 Feb 2023 19:47:30 +0000 (GMT) [thread overview] Message-ID: <20230206194730.B3EF23858D1E@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/cygrunsrv.git;h=405add89a98ee2c995c38dbbc47c8b95a2d721d8 commit 405add89a98ee2c995c38dbbc47c8b95a2d721d8 Author: Corinna Vinschen <vinschen@redhat.com> Date: Mon Feb 6 20:43:38 2023 +0100 handle quoted service paths sanely Diff: --- cygrunsrv.cc | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/cygrunsrv.cc b/cygrunsrv.cc index d6fd76008e51..7b550221d191 100644 --- a/cygrunsrv.cc +++ b/cygrunsrv.cc @@ -1506,16 +1506,31 @@ list_services (const char *server, bool verbose) } if (!QueryServiceConfig (sh, qsc_buf, QSC_BUF_SIZE, &bytes_needed)) - fprintf (stderr, "%s: warning: QueryServiceConfig failed for '%s': " - "Win32 error %u\n%s", appname, srv_buf[i].lpServiceName, - (unsigned) GetLastError (), winerror (GetLastError ())); + { + fprintf (stderr, "%s: warning: QueryServiceConfig failed for '%s': " + "Win32 error %u\n%s", appname, srv_buf[i].lpServiceName, + (unsigned) GetLastError (), winerror (GetLastError ())); + CloseServiceHandle (sh); + sh = (SC_HANDLE) 0; + continue; + } + /* The path might be quoted. Drop the quotes. */ + char service_path[strlen (qsc_buf->lpBinaryPathName) + 1]; + char *endptr = stpcpy (service_path, qsc_buf->lpBinaryPathName[0] == '"' + ? qsc_buf->lpBinaryPathName + 1 + : qsc_buf->lpBinaryPathName); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" + if (endptr > service_path && endptr[-1] == '"') + endptr[-1] = '\0'; +#pragma GCC diagnostic pop /* is this us? */ - else if (same_filename (qsc_buf->lpBinaryPathName, mypath)) - { + if (same_filename (service_path, mypath)) + { if (!verbose) { - if (strcasecmp (qsc_buf->lpBinaryPathName, mypath)) + if (strcasecmp (service_path, mypath)) printf ("(%s)\n", srv_buf[i].lpServiceName); else printf ("%s\n", srv_buf[i].lpServiceName);
reply other threads:[~2023-02-06 19:47 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230206194730.B3EF23858D1E@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-apps-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).