All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: Jonathan Liu <net147@gmail.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH v3] wic: ensure generated disk system identifier is non-zero
Date: Sun, 30 Jul 2017 13:02:36 +0300	[thread overview]
Message-ID: <20170730100236.GA28203@linux.intel.com> (raw)
In-Reply-To: <20170728144527.24322-1-net147@gmail.com>

On Sat, Jul 29, 2017 at 12:45:27AM +1000, Jonathan Liu wrote:
> Zero may be interpreted as no MBR signature present and another
> partitioning program might install a new MBR signature.
> 
> Signed-off-by: Jonathan Liu <net147@gmail.com>
> ---
>  scripts/lib/wic/plugins/imager/direct.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
> index f20d8433f1..fe9b688ab0 100644
> --- a/scripts/lib/wic/plugins/imager/direct.py
> +++ b/scripts/lib/wic/plugins/imager/direct.py
> @@ -297,7 +297,7 @@ class PartitionedImage():
>                            # all partitions (in bytes)
>          self.ptable_format = ptable_format  # Partition table format
>          # Disk system identifier
> -        self.identifier = int.from_bytes(os.urandom(4), 'little')
> +        self.identifier = int.from_bytes(os.urandom(4), 'little') or 0xffffffff
>  

Can we generate random identifier by calling os.urandom again if
self.identifier is zero? Something like this, may be?

while True:
    self.identifier = int.from_bytes(os.urandom(4), 'little')
    if self.identifier:
        break

Assigning constant 0xffffffff can potentially create nonunique identifiers.

>          self.partitions = partitions
>          self.partimages = []
> -- 
> 2.13.2
> 
> -- 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core

-- 
--
Regards,
Ed


  reply	other threads:[~2017-07-30 10:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-28 14:45 [PATCH v3] wic: ensure generated disk system identifier is non-zero Jonathan Liu
2017-07-30 10:02 ` Ed Bartosh [this message]
2017-07-30 10:37   ` Jonathan Liu
2017-07-31  7:28     ` Ed Bartosh
2017-07-31  7:58       ` Jonathan Liu
2017-07-31  8:04         ` Jonathan Liu
2017-07-31  7:59           ` Ed Bartosh

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=20170730100236.GA28203@linux.intel.com \
    --to=ed.bartosh@linux.intel.com \
    --cc=net147@gmail.com \
    --cc=openembedded-core@lists.openembedded.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.