From patchwork Mon Feb 5 11:06:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Achille Fouilleul X-Patchwork-Id: 869234 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4010:c07::240; helo=mail-lf0-x240.google.com; envelope-from=swupdate+bncbdjpl24hzqnrblpv4djqkgqez4lhmia@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="NlHBHbLx"; dkim-atps=neutral Received: from mail-lf0-x240.google.com (mail-lf0-x240.google.com [IPv6:2a00:1450:4010:c07::240]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zZlC61Dk7z9sRV for ; Mon, 5 Feb 2018 22:06:25 +1100 (AEDT) Received: by mail-lf0-x240.google.com with SMTP id r13sf12444513lff.22 for ; Mon, 05 Feb 2018 03:06:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1517828782; cv=pass; d=google.com; s=arc-20160816; b=CfB9QgeUFrdvd6gyCWzYALRPiWZG9wElYjbY2G+hAuWcfMHDnkXhZJGyQZ28LGwGiG ucie/lU7TbAvxpIJUHcE4ML9JrB9Il//y287tYGXl6A9e3eu8FGgSE58xVICt0i3Mi0U eb6hzYeA/Wy+CElbnkaB+5TWkDjqi6rUPA3S9NZumgjmol8KZibIq4XHNKwy88DTdYW0 tgv+TqN3oKG04/U/B9fUQ7gre/AZb1rnP3zpKGuZ5OHTGtf1viV7QejF0rlkitqGHnsD dsjhCqKYRGfV9UMp+ZCECrxPXyIB5IhVlpvQA0Ip9FxBnuU0Q0t7oGoGEzdH7cUeGPCo NQHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:message-id:date:subject:cc:to:from :arc-authentication-results:arc-message-signature:mime-version :sender:dkim-signature:arc-authentication-results; bh=zY1fRqLTaLpSIQZQyEUttqKKqA4mBvY5WNVImwKb1vA=; b=aDb56iApabakwpjkURkTfhEmYw0MiYAg5sAcgPFHRw9TpcBY+8gUphhFDHXUfLEvDg d/GpjFSzcRbxx8PPYMN5rkL7FsSsVBmvfwhM8UAxFeVxLRUNbnPqr1PA7ylsq7XPOSVz XsMRC3NcijEvhy9AfJIL804mA8nlhnM9TgyQr2+SJydMFpuyL2a5Nxb+BB81mAhNPHRB azX6SRzDcDc1tIsDTPtzCQVJH42jEu/zv0tzNXr611AEST3Ikz2A+lGiFUCYuZhzc0KN 0AuiKwozgi/WnW3twtSobpjABsa4tcSfKLWlZqeHtZMbU20jw9FN8KyvdFXN1xX0k5uD 0/Tg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gadz-org.20150623.gappssmtp.com header.s=20150623 header.b=eBWpAUjD; spf=pass (google.com: domain of achille.fouilleul@gadz.org designates 2a00:1450:400c:c09::22f as permitted sender) smtp.mailfrom=achille.fouilleul@gadz.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=zY1fRqLTaLpSIQZQyEUttqKKqA4mBvY5WNVImwKb1vA=; b=NlHBHbLxomlm9Aap9+QSDev3EZxl6J4oixH3XrWLUhTiWcTg0dJ3K1pyCej61L+xVG /ARhUUbGvI5Rw8POwm5pUwK+awQO0VmBE1e8v9/vvBSrPluRQl31MU4ZIQ2xKevThUIx kDDcfVqbuvQnvk4+tUXJMCUb28Xr1wHzYomyiUlinF7Qjl7IRvD3H6sliDIXVd5xaapv rh5WZKptEesFDpBSm4ouNA5KaBriRBxjkh0ksy9eumFJYBPestxExbQT6n4PNLxpXVwm 3+HCOQ1fn9jtDDE6S5rlYjg8q6bPcA5ESHRf6osLo6brnUBH8lHyeP6TvlkVmgu4SzyK i14Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=zY1fRqLTaLpSIQZQyEUttqKKqA4mBvY5WNVImwKb1vA=; b=Vni7Dv51QYE9meQkdT2ytm1WPcGCzSnyFbsZTv+sOakSqMMK27v0X5n/RjEnlndZGb uEFXlyw9mI+1qQ2BzW8q89pWP+DesuSbwNb5QdrheTUgUCadjRpBCk6rqS7fu2tlUvvI FKZeZMCDk9KgY+WYXK76YTz876os6Cs0yTAxI26iiGKq3uoMGSlUk1yOaCMGp4pd//pD NQ8hJbiUBVrBET4Frrilq/EqzyTnqfFVxdWsCZCJHaJlfl6EKNKmuz0ZEkuyz9H9Mjjo fyKKDRBNErjQCbqyrXqe9Z/WA1SwA8z3g2r+dL7Nl/IZbH20C9f62by+jZ1NQZkYKp4P 5ifg== Sender: swupdate@googlegroups.com X-Gm-Message-State: APf1xPCTXL7uuhveeIVOd6Hs5vMykaot9FDGchsvX2MpkuHGXeQw2TwI V5ehNwWxY8FFHJmfOYPLHJc= X-Google-Smtp-Source: AH8x22456fy/PGJQAF/dHkYGND1Y0YgRA42CcEtHTQ4p/rFePb/F0wy0W3o6cb0FCz1IW6yuWg4uEw== X-Received: by 10.46.114.22 with SMTP id n22mr6048ljc.10.1517828782172; Mon, 05 Feb 2018 03:06:22 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.46.46.12 with SMTP id u12ls689028lju.4.gmail; Mon, 05 Feb 2018 03:06:21 -0800 (PST) X-Received: by 10.46.118.14 with SMTP id r14mr400286ljc.8.1517828781139; Mon, 05 Feb 2018 03:06:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517828781; cv=none; d=google.com; s=arc-20160816; b=FVuwLXeulWNmncOUnMnBX7PhOpx6KOxqlp1OQtDon3Fs7cNZCTYG4T5SH4DXWWamiw nDQ/p26P0v0inqDoTexRMrOf4VTtgX4uMLu5GY2FlOu4Q0CzjlSEdO86QQpnvzdlDGOM DI7CBV7LtBfX5LLrDchLC8oNaQf3ePqIDf9git2zRwsHJ/fMV0UqHklS6nOsZbqyVJYu qESWY0+IHlwIpP0A59z+jneJjv6n8HeSYSPXS3H1UXCMosMOAPVIbHkOEas0Fjjd3//p 5kytuMo1rWtd9XpV7OdGNSdgIHkxEm8aL1jo4O4UgsGrqU0RwlWSgqT16DZKu94nnbg7 2MKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=d8xFQg26yfBIQfZZQcJXSCp+9tYzvlKvR/HQ+8Dsteg=; b=Vb8nWe+dZuC99UrDw7zBIHlimz2h341oYKdBBrfWspOES1DZx9S+Fa86QYihHEnt6p tgl2VxynBlyTuIEqsywPrWUucEBxrS7S0Hje+aBdwXXWnXVUKMORfNTAM/PCa9RphuMo 5ys2Vq9ziqtnMr48B4QCSHMch0eG7C+kUkOQgmkOsejaipkYD5K2h8Kkowauyi7NJ3hc x77U2HHwU1uddntJxUjv7i5/nkydaxSoyrh5jnyzmtzRtJv3C17KYVRs1iHAmY6cUOf5 MdY00jNI8c9GMvz+iIy3QxPdCL9j3tK+SbSlRVmJrrDNc9E3JMhlDNP251/p6jD2Gmaz CQvg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gadz-org.20150623.gappssmtp.com header.s=20150623 header.b=eBWpAUjD; spf=pass (google.com: domain of achille.fouilleul@gadz.org designates 2a00:1450:400c:c09::22f as permitted sender) smtp.mailfrom=achille.fouilleul@gadz.org Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com. [2a00:1450:400c:c09::22f]) by gmr-mx.google.com with ESMTPS id b10si448840lfe.4.2018.02.05.03.06.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 03:06:21 -0800 (PST) Received-SPF: pass (google.com: domain of achille.fouilleul@gadz.org designates 2a00:1450:400c:c09::22f as permitted sender) client-ip=2a00:1450:400c:c09::22f; Received: by mail-wm0-x22f.google.com with SMTP id 143so25216421wma.5 for ; Mon, 05 Feb 2018 03:06:21 -0800 (PST) X-Received: by 10.28.144.20 with SMTP id s20mr36946025wmd.149.1517828780653; Mon, 05 Feb 2018 03:06:20 -0800 (PST) Received: from localhost.localdomain ([37.171.179.82]) by smtp.gmail.com with ESMTPSA id i75sm3456145wmg.41.2018.02.05.03.06.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Feb 2018 03:06:20 -0800 (PST) From: Achille Fouilleul To: swupdate@googlegroups.com Cc: Achille Fouilleul Subject: [swupdate] [PATCH 1/2] handlers: fix size of encrypted UBI image Date: Mon, 5 Feb 2018 12:06:13 +0100 Message-Id: <1517828774-1661-1-git-send-email-achille.fouilleul@gadz.org> X-Mailer: git-send-email 1.9.1 X-Original-Sender: achille.fouilleul@gadz.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gadz-org.20150623.gappssmtp.com header.s=20150623 header.b=eBWpAUjD; spf=pass (google.com: domain of achille.fouilleul@gadz.org designates 2a00:1450:400c:c09::22f as permitted sender) smtp.mailfrom=achille.fouilleul@gadz.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Achille Fouilleul Acked-by: Stefano Babic --- handlers/ubivol_handler.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/handlers/ubivol_handler.c b/handlers/ubivol_handler.c index 25ac837..8ba5958 100644 --- a/handlers/ubivol_handler.c +++ b/handlers/ubivol_handler.c @@ -19,6 +19,7 @@ #include "handler.h" #include "flash.h" #include "util.h" +#include "sslapi.h" void ubi_handler(void); @@ -43,6 +44,17 @@ static int update_volume(libubi_t libubi, struct img_type *img, char sbuf[128]; bytes = img->size; + if (img->is_encrypted) { + if (img->compressed) { + ERROR("Decryption of compressed UBI images not supported"); + return -1; + } + if (bytes < AES_BLOCK_SIZE) { + ERROR("Encrypted image size (%lld) too small", bytes); + return -1; + } + bytes -= AES_BLOCK_SIZE; + } if (!libubi) { ERROR("Request to write into UBI, but no UBI on system");