From 1d1041f77de2fb21629e8e8d70ee872189f2654b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20P=C3=ADsa=C5=99?= Date: Wed, 16 Mar 2016 21:13:59 +0100 Subject: [PATCH] Do not use dolar in formatting strings ISO C 99 does not support "$" to control print(3) arguments order. This is not support on mingw platform. This patch changes the library code in order not to use it. It sucks because it makes the code less elegant and less readable. The same problem can occur in translated messages. I worry translations without capability of words reordering will be dumb. I urge people to use better toolchains. --- po/cs.po | 2 +- src/isds.c | 16 ++++++++-------- src/soap.c | 11 +++++++---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/po/cs.po b/po/cs.po index 53ba254..024ca3d 100644 --- a/po/cs.po +++ b/po/cs.po @@ -1524,7 +1524,7 @@ msgstr "Server odmítl požadavek %s na zprávu s ID %s (kód=%s, zpráva=%s)\n #, c-format msgid "Server did not return any signed data for message ID `%s' on %s request" msgstr "" -"Server nevrátil na požadavek %2$s žádná podepsaná data pro zprávu s ID „%1$s“" +"Server nevrátil žádná podepsaná data pro zprávu s ID „%s“ na požadavek %s" #: src/isds.c:9822 #, c-format diff --git a/src/isds.c b/src/isds.c index e22f81f..3e6a732 100644 --- a/src/isds.c +++ b/src/isds.c @@ -1389,7 +1389,7 @@ isds_error isds_login(struct isds_ctx *context, const char *url, _("Selected authentication method: " "HMAC-based one-time password\n")); authenticator_uri = - "%1$sas/processLogin?type=hotp&uri=%1$sapps/"; + "%sas/processLogin?type=hotp&uri=%sapps/"; break; case OTP_TIME: isds_log(ILF_SEC, ILL_INFO, @@ -1401,16 +1401,16 @@ isds_error isds_login(struct isds_ctx *context, const char *url, "application, requesting server for " "new one.\n")); authenticator_uri = - "%1$sas/processLogin?type=totp&sendSms=true&" - "uri=%1$sapps/"; + "%sas/processLogin?type=totp&sendSms=true&" + "uri=%sapps/"; } else { isds_log(ILF_SEC, ILL_INFO, _("OTP code has been provided by " "application, not requesting server " "for new one.\n")); authenticator_uri = - "%1$sas/processLogin?type=totp&" - "uri=%1$sapps/"; + "%sas/processLogin?type=totp&" + "uri=%sapps/"; } break; default: @@ -1419,7 +1419,7 @@ isds_error isds_login(struct isds_ctx *context, const char *url, "method requested by application")); return IE_ENUM; } - if (-1 == isds_asprintf(&context->url, authenticator_uri, url)) + if (-1 == isds_asprintf(&context->url, authenticator_uri, url, url)) return IE_NOMEM; } } else { @@ -5452,7 +5452,7 @@ static isds_error _isds_request_totp_code(struct isds_ctx *context, { char *new_url = NULL; if ((err = _isds_build_url_from_context(context, - "%1$.*2$sasws/changePassword", &new_url))) { + "%.*sasws/changePassword", &new_url))) { goto leave; } saved_url = context->url; @@ -5770,7 +5770,7 @@ isds_error isds_change_password(struct isds_ctx *context, { char *new_url = NULL; if ((err = _isds_build_url_from_context(context, - "%1$.*2$sasws/changePassword", &new_url))) { + "%.*sasws/changePassword", &new_url))) { goto leave; } saved_url = context->url; diff --git a/src/soap.c b/src/soap.c index 1b45e9e..f0b17ab 100644 --- a/src/soap.c +++ b/src/soap.c @@ -1510,8 +1510,10 @@ leave: /* Build new URL from current @context and template. * @context is context carrying an URL - * @template is printf(3) format string. First argument is string of base URL - * found in @context, second argument is length of the base URL. + * @template is printf(3) format string. First argument is length of the base + * URL found in @context, second argument is the base URL, third argument is + * again the base URL. + * XXX: We cannot use "$" formatting character because it's not in the ISO C99. * @new_url is newly allocated URL built from @template. Caller must free it. * Return IE_SUCCESS, or corresponding error code and @new_url will not be * allocated. @@ -1544,7 +1546,8 @@ _hidden isds_error _isds_build_url_from_context(struct isds_ctx *context, length++; /* Build new URL */ - if (-1 == isds_asprintf(new_url, template, context->url, length)) + if (-1 == isds_asprintf(new_url, template, length, context->url, + context->url)) return IE_NOMEM; return IE_SUCCESS; @@ -1565,7 +1568,7 @@ _hidden isds_error _isds_invalidate_otp_cookie(struct isds_ctx *context) { /* Build logout URL */ /*"https://DOMAINNAME/as/processLogout?uri=https://DOMAINNAME/apps/DS/WEB_SERVICE_ENDPOINT"*/ err = _isds_build_url_from_context(context, - "%1$.*2$sas/processLogout?uri=%1$sDS/dz", &url); + "%.*sas/processLogout?uri=%sDS/dz", &url); if (err) return err; /* Invalidate the cookie by GET request */ -- 2.11.4.GIT