From patchwork Sun Sep 13 22:54:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shota Shimoyama X-Patchwork-Id: 2303996 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20251104 header.b=GF0SoY2x; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::73e; helo=mail-qk1-x73e.google.com; envelope-from=swupdate+bncbcul34w2suobbjhrt3kqmgqews4ic3a@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-qk1-x73e.google.com (mail-qk1-x73e.google.com [IPv6:2607:f8b0:4864:20::73e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hjzk66SMnz1xws for ; Mon, 14 Sep 2026 19:04:45 +1000 (AEST) Received: by mail-qk1-x73e.google.com with SMTP id af79cd13be357-936e393061dsf487818285a.2 for ; Mon, 14 Sep 2026 02:04:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1789376678; cv=pass; d=google.com; s=arc-20260327; b=fOfnEpU+1VC/4UnjvBWmQUjlShtoAe8ASKFGoxq27feKLjeVwYzr/XRacH0svsnppz /A06oSbQbb/y1WEp2bLhH9OpWWWayE4Kv4sGsDh8YfVbPGcsMjZW0Sfd1SjiKl5OqCbM 0Chw0C9zBCuY2IPw5gCA2RydJU/RsiKaSXs5cPDaUWpulKS5417P6WRfjCVgiFQSs92z rO1VF96cF0B0kTuU9iWWbPH7L42JnixOAEbrY5bAep960mMUXE/0Mla6OvLnyRBDM8Zz TAcXVfVJDQsSDJEtXuxI32j3uItB6ADNgQQdYbIhAGb+UnOSeFA5ylHrbmFAZneh5VEy 8QKQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:subject:from:to:content-language :user-agent:mime-version:date:message-id:sender:dkim-signature; bh=L3ttF3NHiGQ6qrfRNGw6pBaVJlf62wfq+7P8MoQPCH8=; fh=OQFtkMuwHpFmaD4BbGTRW4a7WfxHHQo7uicyAY0FPuk=; b=JbJtQa80r+LmgJF7NT8UcDEfwn1HpHy0xJaOm3mQodmzbhlbXbdBHH/EN7YpAvPSda W6gKp0XZIzN5z4DSUTBETzWGI3OPsuaUPx8C+DUl0tEBZKoEZ3QHGzJdXQ65XUol1Stc t+d7Wm9uS6HVdjBzUoZJ+N2yqVukmPAueE5ekxQaB25xqBKF4Zp5cT4i3C0pMW1e4cGa PWpxF/VTokYJ1mCkQBk0pypsvUDbGBwNak68VUiedqNYqW8zyJwbvHAYNz6RLqgxMuD5 FoFeFPkTDHMCTpCH6wWqzoHOBlzY7C6zw40xbQjYXQHy/8ql4Ldp/zmCr6fAPw0NjFtM Hk4w==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=google header.b=GCZ05T6L; spf=pass (google.com: domain of shota.shimoyama@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=shota.shimoyama@atmark-techno.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com; dara=pass header.i=@googlegroups.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20251104; t=1789376678; x=1789981478; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:content-type:subject:from:to:content-language :user-agent:mime-version:date:message-id:sender:from:to:cc:subject :date:message-id:reply-to:content-type; bh=L3ttF3NHiGQ6qrfRNGw6pBaVJlf62wfq+7P8MoQPCH8=; b=GF0SoY2xc9lnTdRQQNtyLGlYVlW9JDCDd9KNlAJxTae0zGfFnsjHag+Smiu53bKRfY xEtc0AtLacHndu+f0Z8xsR7v9uZSePFWZgNlSlKPqDhvmPBs9xAag/ztmzAtWjDK/m6k XHsCkQYyYuUp+CiuTfa0z4BonA8ARa0LFKQ5RdUp3zKWoalYzUSVnDC9h0qJFPPAL3tB AZC9ICpabIW8AyiI4HKbLKUjARHuOLpPRF+zGkyyrsI/PVBXzoWloXT1C5Qr1JUh5mTq fWEwhKyLXPGjXadN3wPGZG7PJ4LoPcJUghSgd+PCoz9EKc8p1WlqwSZsHyc9pFukh/vi DJsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789376678; x=1789981478; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:content-type:subject:from:to:content-language :user-agent:mime-version:date:message-id:x-gm-gg:x-beenthere :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to:content-type; bh=L3ttF3NHiGQ6qrfRNGw6pBaVJlf62wfq+7P8MoQPCH8=; b=ojxPeiqrMhCwSA4ureAH176arIpM7qanRGHi5ZjzIHooQbQlMro/vo/j8HFKqs0Z4U sWXx0R+7C3sKGaWBZmSgMhpyPkqQ98UQ4/saeRlBjX5s1ifuwrt5FtQI7zMab6Pupe5I R2spktHjwjPK76tgBcpYpC9wtMyOR+qyl5ltiwpYmRzPOrrp/Sg8fG4p63KSoECvBAkZ 34rElgSWCJxRYsAXTiS7xiYqoeVR6UZmaso6SZqb/rid2GcSyHzTW3rvGjB/bU4Pztr8 pJ9X8E0H0Gba/T6EZbbNby7yb511lQfNY5gjayWHh4imrsYF+CI1V0AT+fV2ThFYgKLX ubnw== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AKwUvBx58mYDG4ACeSZvyaf3j5ihEKba1LKKaONx+DuWHdXJkMUTC1oTfHk8o+ztDcyv4aCST7jJ/NNyzQ==@patchwork.ozlabs.org X-Gm-Message-State: AFuF++nyEb5fZQp6rKC8YfnVCo446uYV8KTRqMb7wwK4fOhKf1Yx4xwL hsTSiP8pLFGkYF4y/YBqY35d7Wetw6q9wxqo8lcTGNR8Fvaj9YyuiPmE X-Received: by 2002:a05:620a:468b:b0:936:623e:2603 with SMTP id af79cd13be357-93a2985c9cfmr216488485a.17.1789376678289; Mon, 14 Sep 2026 02:04:38 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com; h="ATskLderPRm+oLeJuJR9+wkn3AlWoHFH9e7x9gzqaM/dgndZCQ==" Received: by 2002:a05:622a:1813:b0:52d:8022:a0cf with SMTP id d75a77b69052e-530fe610bd9ls31807141cf.1.-pod-prod-05-us; Mon, 14 Sep 2026 02:04:35 -0700 (PDT) X-Received: by 2002:a05:620a:2853:b0:939:6dfa:48fc with SMTP id af79cd13be357-93a29bfa159mr185466785a.50.1789376675767; Mon, 14 Sep 2026 02:04:35 -0700 (PDT) Received: by 2002:a05:620a:6342:b0:939:7b46:f3b5 with SMTP id af79cd13be357-93a29e1c370ms85a; Mon, 14 Sep 2026 01:55:00 -0700 (PDT) X-Received: by 2002:a05:622a:401a:b0:530:dab5:d43a with SMTP id d75a77b69052e-5310cf4084emr22486751cf.24.1789376099789; Mon, 14 Sep 2026 01:54:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1789376099; cv=none; d=google.com; s=arc-20260327; b=P7ZiBTFn+rzhFRvOd7ohF7OVUqWK0cgH6mfidmlxbGfRiZWLR4IaczLGcTOaQT/RNe dB/1rPCg9MHdgD+XMrdelB0eLpDrNpLWd/fU7S8irla2hNIAiiQWatuo+BSF6ZzrwdbG 2JcLp8pPAS5Lll0e3I6tpKJBw09rjQQCP0BdVKc1i615o3ZHq6HhVMb8D417TbYFQj65 lmc/u3c2FuEPFcSd2sF7AzBTqkv/nXYm0AUx4J+qc9cLDjAQHsZ/knF72FhWqeUU1fHU LekdJ1hghcdo2PpYm4PLMmH4xI/ZDNR+LWWEf/7M/ZaYyxnjWeOzuP/moUsLxFUmTtD7 zTIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:dkim-signature; bh=EmXQlj7ijMKpe+K2jE7exdI4mnfYg8yy6bH06GL2sG4=; fh=nvZsCFpxgpf+fsVXzjnWA8g1K3V/kNbRAKogjNDW4HY=; b=V8xsFTkFvxWqAv7deSrHXWCCmGOtFghyLF1Fg8VGma74MSVaF3IqOagatCnpXEUyiE LQwcLVgZLbK0eUqJ/bfPlSN9ggLFS4ux+rUdiBJgRsdUfnZfkqMyGIb4GzK19pJXw7gu S7DOr2OULtNCgk1+93MQF4QBmsxs0i4BtnUAr9abfVA/s34c/rw7Xh7KOSF3+nSYv5V3 wZKLQvTg0GQyRuee3tlJ2CmU5Ck7hpE6IhDU33ngjD0rYbmEb4ck4OuRFmkH1upfmExJ GqMmfFyUvKsxr+fRgVsO+FVjCZPOlND0pGfG7q9mhA22v/7DGdBsZzHNZm7HkdhDhQ+P L5bw==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=google header.b=GCZ05T6L; spf=pass (google.com: domain of shota.shimoyama@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=shota.shimoyama@atmark-techno.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com; dara=pass header.i=@googlegroups.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTPS id 6a1803df08f44-9120f20a4b9si3372226d6.2.2026.09.14.01.54.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2026 01:54:59 -0700 (PDT) Received-SPF: pass (google.com: domain of shota.shimoyama@atmark-techno.com designates 35.74.137.57 as permitted sender) client-ip=35.74.137.57; Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by gw2.atmark-techno.com (Postfix) with ESMTPS id 174B736B for ; Mon, 14 Sep 2026 17:54:58 +0900 (JST) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-38ea32e57e2so6288042a91.1 for ; Mon, 14 Sep 2026 01:54:58 -0700 (PDT) X-Gm-Gg: AYBFou3RinAZvDqh0DdAD0lIkdA0xqXi3ZgoHzh1IpAEarPG/1kXCx5u7kwLvMxSnLI 1WfjPw0OECZFNt8cHyI6ZEr/CAsK19RQT+GlCkBgIoW1IzMi5f+YEDjhjZWQEsWx6Zx5wDdLnjX fwzbDs516Hayk8fVyW17iH7P+C/a0A62AnBrM4E+bz3rssgLMPG+raI0TS1GMxMVn6GwkCwhoqs DGVbe9gbmI2yISATyYUxlWrYPq7fc4wymyi8VNMtE2fo12jrJ19tWxvxdMei89jhIz6IgSl4Pxx jMgSvAydNqvpd762ZeVPkcGbNXI0p+qOWLO0/o31uPRHbtv5carLqj1y5v8Gioah5eQETFf4txG 08wTDTpAyxWoBZD+4IGRnGalrESBARWxfBohQLFKLmy957vyr9IdbCl8xu4QODNo= X-Received: by 2002:a17:90b:554b:b0:39d:f70f:f021 with SMTP id 98e67ed59e1d1-39df710bf86mr217277a91.9.1789376096965; Mon, 14 Sep 2026 01:54:56 -0700 (PDT) X-Received: by 2002:a17:90b:554b:b0:39d:f70f:f021 with SMTP id 98e67ed59e1d1-39df710bf86mr217237a91.9.1789376096510; Mon, 14 Sep 2026 01:54:56 -0700 (PDT) Received: from [172.16.1.4] (sodcd-04p2-40.ppp11.odn.ad.jp. [203.139.65.40]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39d994872e0sm19967815a91.8.2026.09.14.01.54.55 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Sep 2026 01:54:55 -0700 (PDT) Message-ID: <7caae01a-66b3-48ca-9dc2-c317353daeac@atmark-techno.com> Date: Mon, 14 Sep 2026 17:54:57 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: swupdate@googlegroups.com From: Shota Shimoyama Subject: [swupdate] [PATCH] hawkbit: Escape JSON special characters in deploymentBase feedback details X-Original-Sender: shota.shimoyama@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=google header.b=GCZ05T6L; spf=pass (google.com: domain of shota.shimoyama@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=shota.shimoyama@atmark-techno.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com; dara=pass header.i=@googlegroups.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , When sending a POST request with deployment feedback to hawkBit, the payload for "details" was built by raw string concatenation of TRACE/ERROR messages. If these messages contained JSON special characters, the generated JSON became invalid, causing hawkBit to return a 400 Bad Request with the following response body: { "errorCode": "hawkbit.server.error.rest.body.notReadable", "exceptionClass": "org.eclipse.hawkbit.rest.exception.MessageNotReadableException", "message": "The given request body is not well formed" } Particularly when this error occurs during feedback requests intended to notify final statuses like "finished" or "error", hawkBit fails to register the completion of the action. Consequently, hawkBit keeps the action active, causing SWUpdate to repeatedly attempt the update at every polling interval. To ensure robust serialization of arbitrary script outputs (stdout/stderr) from run_system_cmd(), modify server_create_details() to construct the JSON array using json-c. This guarantees proper JSON escaping for all special characters in the deploymentBase feedback details. Signed-off-by: Shota Shimoyama Reviewed-by: Dominique Martinet --- suricatta/server_hawkbit.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c index a9d09ac5..781c023a 100644 --- a/suricatta/server_hawkbit.c +++ b/suricatta/server_hawkbit.c @@ -367,27 +367,35 @@ cleanup: static char *server_create_details(int numdetails, const char *details[]) { - int i, ret; - char *prev = NULL; - char *next = NULL; + int i; + struct json_object *jarray = NULL; + struct json_object *jstr = NULL; + char *result = NULL; /* * Note: NEVER call TRACE / ERROR inside this function * because it generates a recursion */ + + jarray = json_object_new_array_ext(numdetails); + if (!jarray) + return NULL; + for (i = 0; i < numdetails; i++) { - if (i == 0) { - ret = asprintf(&next, "\"%s\"", details[i]); - } else { - ret = asprintf(&next, "%s,\"%s\"", prev, details[i]); - free(prev); - } - if (ret == ENOMEM_ASPRINTF) + jstr = json_object_new_string(details[i]); + if (!jstr) { + json_object_put(jarray); return NULL; - prev = next; + } + json_object_array_add(jarray, jstr); } - return next; + const char *json_str = json_object_to_json_string(jarray); + + result = json_str ? strdup(json_str) : NULL; + + json_object_put(jarray); + return result; } server_op_res_t @@ -421,7 +429,7 @@ server_send_deployment_reply(channel_t *channel, "finished": "%s" }, "execution": "%s", - "details" : [ %s ] + "details" : %s } } ); @@ -436,7 +444,7 @@ server_send_deployment_reply(channel_t *channel, if (ENOMEM_ASPRINTF == asprintf(&json_reply_string, json_hawkbit_deployment_feedback, action_id, fdate, job_cnt_cur, job_cnt_max, finished, - execution_status, detail ? detail : " ")) { + execution_status, detail ? detail : "[]")) { ERROR("hawkBit server reply cannot be sent because of OOM."); result = SERVER_EINIT; goto cleanup;