Can a running Squeak program look at a Squeak image file and know if it is a good image?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can a running Squeak program look at a Squeak image file and know if it is a good image?

Louis LaBrunda
Hi All,

Can a running Squeak program look at a Squeak image file and know if it is a good image?  I'm
working on a program that the user won't have easy access to.  I would like to allow its
replacement with a new version.  I think I know how to do that but would like to see if I can
program in some protection from the user replacing the image with a bad or completely wrong
file.  Any ideas?


Lou
--
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can a running Squeak program look at a Squeak image file and know if it is a good image?

David T. Lewis
Hi Lou,

A simple check is to look at the first bytes of the image file, which
define the image format number. If the image format is something
reasonable (presumably the same as whatever image you are replacing in
most cases), then you know that it is a Squeak image file, although this
will not tell you if the actual image is valid.

To do this from a running Squeak image, try loading the ImageFormat
package from the VMMaker repository on squeaksource.com. Look at the class
comments, and you will find methods for reading the image format number
from a file stream.

There is also a C program called ckformat.c at
http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/src/. The C code is
automatically generated from the ImageFormat package, so they the do the
same thing. If you want to do the test from a shell script, as opposed to
doing it from the running image, then you can use this C program.

Of course in theory you can load an entire image file into a VM simulator
with the VMMaker package, but that would not be a practical test for what
you are trying to accomplish.

If you need a better test of "valid" then you might consider using
OSProcess/CommandShell to actually run the image file and see if it works.
Probably you would do something like run it with a PipeableOSProcess
connected to your main Squeak image, and just kill the image under test
once you have confirmed that it runs.

Dave

> Hi All,
>
> Can a running Squeak program look at a Squeak image file and know if it is
> a good image?  I'm
> working on a program that the user won't have easy access to.  I would
> like to allow its
> replacement with a new version.  I think I know how to do that but would
> like to see if I can
> program in some protection from the user replacing the image with a bad or
> completely wrong
> file.  Any ideas?
>
>
> Lou
> --
> Louis LaBrunda
> Keystone Software Corp.
> SkypeMe callto://PhotonDemon
>
>
>



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can a running Squeak program look at a Squeak image file and know if it is a good image?

Louis LaBrunda
Hi Dave,

Thanks you very much for the prompt reply.  I loaded the ImageFormat package as you suggested
into a fairly new 32 bit image.  But when I try ImageFormat fromFile: to that image of the
image with my program, I get an "unrecognized image format" error.  I will keep trying more
after lunch but for now I don't get it?

Lou


On Tue, 25 Jul 2017 11:18:05 -0400 (EDT), "David T. Lewis" <[hidden email]> wrote:

>Hi Lou,
>
>A simple check is to look at the first bytes of the image file, which
>define the image format number. If the image format is something
>reasonable (presumably the same as whatever image you are replacing in
>most cases), then you know that it is a Squeak image file, although this
>will not tell you if the actual image is valid.
>
>To do this from a running Squeak image, try loading the ImageFormat
>package from the VMMaker repository on squeaksource.com. Look at the class
>comments, and you will find methods for reading the image format number
>from a file stream.
>
>There is also a C program called ckformat.c at
>http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/src/. The C code is
>automatically generated from the ImageFormat package, so they the do the
>same thing. If you want to do the test from a shell script, as opposed to
>doing it from the running image, then you can use this C program.
>
>Of course in theory you can load an entire image file into a VM simulator
>with the VMMaker package, but that would not be a practical test for what
>you are trying to accomplish.
>
>If you need a better test of "valid" then you might consider using
>OSProcess/CommandShell to actually run the image file and see if it works.
>Probably you would do something like run it with a PipeableOSProcess
>connected to your main Squeak image, and just kill the image under test
>once you have confirmed that it runs.
>
>Dave
>
>> Hi All,
>>
>> Can a running Squeak program look at a Squeak image file and know if it is
>> a good image?  I'm
>> working on a program that the user won't have easy access to.  I would
>> like to allow its
>> replacement with a new version.  I think I know how to do that but would
>> like to see if I can
>> program in some protection from the user replacing the image with a bad or
>> completely wrong
>> file.  Any ideas?
>>
>>
>> Lou
>> --
>> Louis LaBrunda
>> Keystone Software Corp.
>> SkypeMe callto://PhotonDemon
>>
>>
>>
>
>
>
--
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can a running Squeak program look at a Squeak image file and know if it is a good image?

timrowledge
Don’t forget to start off by checking the file size and some variety of hash - MD5 seems to be a common utility. And zip the file(s) when ending both for the obvious speed reason and as another sort of integrity check.

Or, consider not sending entire images, but using an update stream private to your project. Hell, you could even use my MQTTClient thing to subscribe to an update topic...

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Useful random insult:- A prime candidate for natural deselection.



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can a running Squeak program look at a Squeak image file and know if it is a good image?

David T. Lewis
In reply to this post by Louis LaBrunda
Hi Lou,

Ugh, I think that was due to a bug that I fixed not too long ago (some
missing methods for the latest Spur formats IIRC). I thought I had
uploaded the fix but I do not see it in the repository. My apologies, I
will address it as quickly as I can, but it might not be until tomorrow.

Sorry,
Dave


> Hi Dave,
>
> Thanks you very much for the prompt reply.  I loaded the ImageFormat
> package as you suggested
> into a fairly new 32 bit image.  But when I try ImageFormat fromFile: to
> that image of the
> image with my program, I get an "unrecognized image format" error.  I will
> keep trying more
> after lunch but for now I don't get it?
>
> Lou
>
>
> On Tue, 25 Jul 2017 11:18:05 -0400 (EDT), "David T. Lewis"
> <[hidden email]> wrote:
>
>>Hi Lou,
>>
>>A simple check is to look at the first bytes of the image file, which
>>define the image format number. If the image format is something
>>reasonable (presumably the same as whatever image you are replacing in
>>most cases), then you know that it is a Squeak image file, although this
>>will not tell you if the actual image is valid.
>>
>>To do this from a running Squeak image, try loading the ImageFormat
>>package from the VMMaker repository on squeaksource.com. Look at the
>> class
>>comments, and you will find methods for reading the image format number
>>from a file stream.
>>
>>There is also a C program called ckformat.c at
>>http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/src/. The C code is
>>automatically generated from the ImageFormat package, so they the do the
>>same thing. If you want to do the test from a shell script, as opposed to
>>doing it from the running image, then you can use this C program.
>>
>>Of course in theory you can load an entire image file into a VM simulator
>>with the VMMaker package, but that would not be a practical test for what
>>you are trying to accomplish.
>>
>>If you need a better test of "valid" then you might consider using
>>OSProcess/CommandShell to actually run the image file and see if it
>> works.
>>Probably you would do something like run it with a PipeableOSProcess
>>connected to your main Squeak image, and just kill the image under test
>>once you have confirmed that it runs.
>>
>>Dave
>>
>>> Hi All,
>>>
>>> Can a running Squeak program look at a Squeak image file and know if it
>>> is
>>> a good image?  I'm
>>> working on a program that the user won't have easy access to.  I would
>>> like to allow its
>>> replacement with a new version.  I think I know how to do that but
>>> would
>>> like to see if I can
>>> program in some protection from the user replacing the image with a bad
>>> or
>>> completely wrong
>>> file.  Any ideas?
>>>
>>>
>>> Lou
>>> --
>>> Louis LaBrunda
>>> Keystone Software Corp.
>>> SkypeMe callto://PhotonDemon
>>>
>>>
>>>
>>
>>
>>
> --
> Louis LaBrunda
> Keystone Software Corp.
> SkypeMe callto://PhotonDemon
>
>
>



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can a running Squeak program look at a Squeak image file and know if it is a good image?

Louis LaBrunda
Hi Dave,

Thanks Dave.  I will check tomorrow.  For now I will assume it will get fixed and work around
it.

Lou

On Tue, 25 Jul 2017 13:47:12 -0400 (EDT), "David T. Lewis" <[hidden email]> wrote:

>Hi Lou,
>
>Ugh, I think that was due to a bug that I fixed not too long ago (some
>missing methods for the latest Spur formats IIRC). I thought I had
>uploaded the fix but I do not see it in the repository. My apologies, I
>will address it as quickly as I can, but it might not be until tomorrow.
>
>Sorry,
>Dave
>
>
>> Hi Dave,
>>
>> Thanks you very much for the prompt reply.  I loaded the ImageFormat
>> package as you suggested
>> into a fairly new 32 bit image.  But when I try ImageFormat fromFile: to
>> that image of the
>> image with my program, I get an "unrecognized image format" error.  I will
>> keep trying more
>> after lunch but for now I don't get it?
>>
>> Lou
>>
>>
>> On Tue, 25 Jul 2017 11:18:05 -0400 (EDT), "David T. Lewis"
>> <[hidden email]> wrote:
>>
>>>Hi Lou,
>>>
>>>A simple check is to look at the first bytes of the image file, which
>>>define the image format number. If the image format is something
>>>reasonable (presumably the same as whatever image you are replacing in
>>>most cases), then you know that it is a Squeak image file, although this
>>>will not tell you if the actual image is valid.
>>>
>>>To do this from a running Squeak image, try loading the ImageFormat
>>>package from the VMMaker repository on squeaksource.com. Look at the
>>> class
>>>comments, and you will find methods for reading the image format number
>>>from a file stream.
>>>
>>>There is also a C program called ckformat.c at
>>>http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/src/. The C code is
>>>automatically generated from the ImageFormat package, so they the do the
>>>same thing. If you want to do the test from a shell script, as opposed to
>>>doing it from the running image, then you can use this C program.
>>>
>>>Of course in theory you can load an entire image file into a VM simulator
>>>with the VMMaker package, but that would not be a practical test for what
>>>you are trying to accomplish.
>>>
>>>If you need a better test of "valid" then you might consider using
>>>OSProcess/CommandShell to actually run the image file and see if it
>>> works.
>>>Probably you would do something like run it with a PipeableOSProcess
>>>connected to your main Squeak image, and just kill the image under test
>>>once you have confirmed that it runs.
>>>
>>>Dave
>>>
>>>> Hi All,
>>>>
>>>> Can a running Squeak program look at a Squeak image file and know if it
>>>> is
>>>> a good image?  I'm
>>>> working on a program that the user won't have easy access to.  I would
>>>> like to allow its
>>>> replacement with a new version.  I think I know how to do that but
>>>> would
>>>> like to see if I can
>>>> program in some protection from the user replacing the image with a bad
>>>> or
>>>> completely wrong
>>>> file.  Any ideas?
>>>>
>>>>
>>>> Lou
>>>> --
>>>> Louis LaBrunda
>>>> Keystone Software Corp.
>>>> SkypeMe callto://PhotonDemon
>>>>
>>>>
>>>>
>>>
>>>
>>>
>> --
>> Louis LaBrunda
>> Keystone Software Corp.
>> SkypeMe callto://PhotonDemon
>>
>>
>>
>
>
>
--
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can a running Squeak program look at a Squeak image file and know if it is a good image?

David T. Lewis
I guess I just forgot to upload it from my package-cache. Please try again
with the ImageFormat-dtl.26 that I just uploaded, it should work now. Sorry
for the confusion.

Dave


On Tue, Jul 25, 2017 at 01:54:43PM -0400, Louis LaBrunda wrote:

> Hi Dave,
>
> Thanks Dave.  I will check tomorrow.  For now I will assume it will get fixed and work around
> it.
>
> Lou
>
> On Tue, 25 Jul 2017 13:47:12 -0400 (EDT), "David T. Lewis" <[hidden email]> wrote:
>
> >Hi Lou,
> >
> >Ugh, I think that was due to a bug that I fixed not too long ago (some
> >missing methods for the latest Spur formats IIRC). I thought I had
> >uploaded the fix but I do not see it in the repository. My apologies, I
> >will address it as quickly as I can, but it might not be until tomorrow.
> >
> >Sorry,
> >Dave
> >
> >
> >> Hi Dave,
> >>
> >> Thanks you very much for the prompt reply.  I loaded the ImageFormat
> >> package as you suggested
> >> into a fairly new 32 bit image.  But when I try ImageFormat fromFile: to
> >> that image of the
> >> image with my program, I get an "unrecognized image format" error.  I will
> >> keep trying more
> >> after lunch but for now I don't get it?
> >>
> >> Lou
> >>
> >>
> >> On Tue, 25 Jul 2017 11:18:05 -0400 (EDT), "David T. Lewis"
> >> <[hidden email]> wrote:
> >>
> >>>Hi Lou,
> >>>
> >>>A simple check is to look at the first bytes of the image file, which
> >>>define the image format number. If the image format is something
> >>>reasonable (presumably the same as whatever image you are replacing in
> >>>most cases), then you know that it is a Squeak image file, although this
> >>>will not tell you if the actual image is valid.
> >>>
> >>>To do this from a running Squeak image, try loading the ImageFormat
> >>>package from the VMMaker repository on squeaksource.com. Look at the
> >>> class
> >>>comments, and you will find methods for reading the image format number
> >>>from a file stream.
> >>>
> >>>There is also a C program called ckformat.c at
> >>>http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/src/. The C code is
> >>>automatically generated from the ImageFormat package, so they the do the
> >>>same thing. If you want to do the test from a shell script, as opposed to
> >>>doing it from the running image, then you can use this C program.
> >>>
> >>>Of course in theory you can load an entire image file into a VM simulator
> >>>with the VMMaker package, but that would not be a practical test for what
> >>>you are trying to accomplish.
> >>>
> >>>If you need a better test of "valid" then you might consider using
> >>>OSProcess/CommandShell to actually run the image file and see if it
> >>> works.
> >>>Probably you would do something like run it with a PipeableOSProcess
> >>>connected to your main Squeak image, and just kill the image under test
> >>>once you have confirmed that it runs.
> >>>
> >>>Dave
> >>>
> >>>> Hi All,
> >>>>
> >>>> Can a running Squeak program look at a Squeak image file and know if it
> >>>> is
> >>>> a good image?  I'm
> >>>> working on a program that the user won't have easy access to.  I would
> >>>> like to allow its
> >>>> replacement with a new version.  I think I know how to do that but
> >>>> would
> >>>> like to see if I can
> >>>> program in some protection from the user replacing the image with a bad
> >>>> or
> >>>> completely wrong
> >>>> file.  Any ideas?
> >>>>
> >>>>
> >>>> Lou
> >>>> --
> >>>> Louis LaBrunda
> >>>> Keystone Software Corp.
> >>>> SkypeMe callto://PhotonDemon
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >> --
> >> Louis LaBrunda
> >> Keystone Software Corp.
> >> SkypeMe callto://PhotonDemon
> >>
> >>
> >>
> >
> >
> >
> --
> Louis LaBrunda
> Keystone Software Corp.
> SkypeMe callto://PhotonDemon
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can a running Squeak program look at a Squeak image file and know if it is a good image?

Louis LaBrunda
Hey Dave,

I'm sure I'm messing something up but I can't find ImageFormat-dtl.26, they only go up to
ImageFormat-dtl.12.  Am I looking in the wrong place?

Lou


On Tue, 25 Jul 2017 14:06:30 -0400, "David T. Lewis" <[hidden email]> wrote:

>I guess I just forgot to upload it from my package-cache. Please try again
>with the ImageFormat-dtl.26 that I just uploaded, it should work now. Sorry
>for the confusion.
>
>Dave
>
>
>On Tue, Jul 25, 2017 at 01:54:43PM -0400, Louis LaBrunda wrote:
>> Hi Dave,
>>
>> Thanks Dave.  I will check tomorrow.  For now I will assume it will get fixed and work around
>> it.
>>
>> Lou
>>
>> On Tue, 25 Jul 2017 13:47:12 -0400 (EDT), "David T. Lewis" <[hidden email]> wrote:
>>
>> >Hi Lou,
>> >
>> >Ugh, I think that was due to a bug that I fixed not too long ago (some
>> >missing methods for the latest Spur formats IIRC). I thought I had
>> >uploaded the fix but I do not see it in the repository. My apologies, I
>> >will address it as quickly as I can, but it might not be until tomorrow.
>> >
>> >Sorry,
>> >Dave
>> >
>> >
>> >> Hi Dave,
>> >>
>> >> Thanks you very much for the prompt reply.  I loaded the ImageFormat
>> >> package as you suggested
>> >> into a fairly new 32 bit image.  But when I try ImageFormat fromFile: to
>> >> that image of the
>> >> image with my program, I get an "unrecognized image format" error.  I will
>> >> keep trying more
>> >> after lunch but for now I don't get it?
>> >>
>> >> Lou
>> >>
>> >>
>> >> On Tue, 25 Jul 2017 11:18:05 -0400 (EDT), "David T. Lewis"
>> >> <[hidden email]> wrote:
>> >>
>> >>>Hi Lou,
>> >>>
>> >>>A simple check is to look at the first bytes of the image file, which
>> >>>define the image format number. If the image format is something
>> >>>reasonable (presumably the same as whatever image you are replacing in
>> >>>most cases), then you know that it is a Squeak image file, although this
>> >>>will not tell you if the actual image is valid.
>> >>>
>> >>>To do this from a running Squeak image, try loading the ImageFormat
>> >>>package from the VMMaker repository on squeaksource.com. Look at the
>> >>> class
>> >>>comments, and you will find methods for reading the image format number
>> >>>from a file stream.
>> >>>
>> >>>There is also a C program called ckformat.c at
>> >>>http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/src/. The C code is
>> >>>automatically generated from the ImageFormat package, so they the do the
>> >>>same thing. If you want to do the test from a shell script, as opposed to
>> >>>doing it from the running image, then you can use this C program.
>> >>>
>> >>>Of course in theory you can load an entire image file into a VM simulator
>> >>>with the VMMaker package, but that would not be a practical test for what
>> >>>you are trying to accomplish.
>> >>>
>> >>>If you need a better test of "valid" then you might consider using
>> >>>OSProcess/CommandShell to actually run the image file and see if it
>> >>> works.
>> >>>Probably you would do something like run it with a PipeableOSProcess
>> >>>connected to your main Squeak image, and just kill the image under test
>> >>>once you have confirmed that it runs.
>> >>>
>> >>>Dave
>> >>>
>> >>>> Hi All,
>> >>>>
>> >>>> Can a running Squeak program look at a Squeak image file and know if it
>> >>>> is
>> >>>> a good image?  I'm
>> >>>> working on a program that the user won't have easy access to.  I would
>> >>>> like to allow its
>> >>>> replacement with a new version.  I think I know how to do that but
>> >>>> would
>> >>>> like to see if I can
>> >>>> program in some protection from the user replacing the image with a bad
>> >>>> or
>> >>>> completely wrong
>> >>>> file.  Any ideas?
>> >>>>
>> >>>>
>> >>>> Lou
>> >>>> --
>> >>>> Louis LaBrunda
>> >>>> Keystone Software Corp.
>> >>>> SkypeMe callto://PhotonDemon
>> >>>>
>> >>>>
>> >>>>
>> >>>
>> >>>
>> >>>
>> >> --
>> >> Louis LaBrunda
>> >> Keystone Software Corp.
>> >> SkypeMe callto://PhotonDemon
>> >>
>> >>
>> >>
>> >
>> >
>> >
>> --
>> Louis LaBrunda
>> Keystone Software Corp.
>> SkypeMe callto://PhotonDemon
>>
>>
>
--
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can a running Squeak program look at a Squeak image file and know if it is a good image?

David T. Lewis
Lou,

So sorry, I think I need a new brain today. The repository is on
source.squeak.org, not on squeaksource.com as I said in my earlier mail.
The stuff on squeaksource.com is ancient, and all recent VM related work
was moved to source.squeak.org a long time ago.

My apologies again!

Dave

> Hey Dave,
>
> I'm sure I'm messing something up but I can't find ImageFormat-dtl.26,
> they only go up to
> ImageFormat-dtl.12.  Am I looking in the wrong place?
>
> Lou
>
>
> On Tue, 25 Jul 2017 14:06:30 -0400, "David T. Lewis" <[hidden email]>
> wrote:
>
>>I guess I just forgot to upload it from my package-cache. Please try
>> again
>>with the ImageFormat-dtl.26 that I just uploaded, it should work now.
>> Sorry
>>for the confusion.
>>
>>Dave
>>
>>
>>On Tue, Jul 25, 2017 at 01:54:43PM -0400, Louis LaBrunda wrote:
>>> Hi Dave,
>>>
>>> Thanks Dave.  I will check tomorrow.  For now I will assume it will get
>>> fixed and work around
>>> it.
>>>
>>> Lou
>>>
>>> On Tue, 25 Jul 2017 13:47:12 -0400 (EDT), "David T. Lewis"
>>> <[hidden email]> wrote:
>>>
>>> >Hi Lou,
>>> >
>>> >Ugh, I think that was due to a bug that I fixed not too long ago (some
>>> >missing methods for the latest Spur formats IIRC). I thought I had
>>> >uploaded the fix but I do not see it in the repository. My apologies,
>>> I
>>> >will address it as quickly as I can, but it might not be until
>>> tomorrow.
>>> >
>>> >Sorry,
>>> >Dave
>>> >
>>> >
>>> >> Hi Dave,
>>> >>
>>> >> Thanks you very much for the prompt reply.  I loaded the ImageFormat
>>> >> package as you suggested
>>> >> into a fairly new 32 bit image.  But when I try ImageFormat
>>> fromFile: to
>>> >> that image of the
>>> >> image with my program, I get an "unrecognized image format" error.
>>> I will
>>> >> keep trying more
>>> >> after lunch but for now I don't get it?
>>> >>
>>> >> Lou
>>> >>
>>> >>
>>> >> On Tue, 25 Jul 2017 11:18:05 -0400 (EDT), "David T. Lewis"
>>> >> <[hidden email]> wrote:
>>> >>
>>> >>>Hi Lou,
>>> >>>
>>> >>>A simple check is to look at the first bytes of the image file,
>>> which
>>> >>>define the image format number. If the image format is something
>>> >>>reasonable (presumably the same as whatever image you are replacing
>>> in
>>> >>>most cases), then you know that it is a Squeak image file, although
>>> this
>>> >>>will not tell you if the actual image is valid.
>>> >>>
>>> >>>To do this from a running Squeak image, try loading the ImageFormat
>>> >>>package from the VMMaker repository on squeaksource.com. Look at the
>>> >>> class
>>> >>>comments, and you will find methods for reading the image format
>>> number
>>> >>>from a file stream.
>>> >>>
>>> >>>There is also a C program called ckformat.c at
>>> >>>http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/src/. The C code
>>> is
>>> >>>automatically generated from the ImageFormat package, so they the do
>>> the
>>> >>>same thing. If you want to do the test from a shell script, as
>>> opposed to
>>> >>>doing it from the running image, then you can use this C program.
>>> >>>
>>> >>>Of course in theory you can load an entire image file into a VM
>>> simulator
>>> >>>with the VMMaker package, but that would not be a practical test for
>>> what
>>> >>>you are trying to accomplish.
>>> >>>
>>> >>>If you need a better test of "valid" then you might consider using
>>> >>>OSProcess/CommandShell to actually run the image file and see if it
>>> >>> works.
>>> >>>Probably you would do something like run it with a PipeableOSProcess
>>> >>>connected to your main Squeak image, and just kill the image under
>>> test
>>> >>>once you have confirmed that it runs.
>>> >>>
>>> >>>Dave
>>> >>>
>>> >>>> Hi All,
>>> >>>>
>>> >>>> Can a running Squeak program look at a Squeak image file and know
>>> if it
>>> >>>> is
>>> >>>> a good image?  I'm
>>> >>>> working on a program that the user won't have easy access to.  I
>>> would
>>> >>>> like to allow its
>>> >>>> replacement with a new version.  I think I know how to do that but
>>> >>>> would
>>> >>>> like to see if I can
>>> >>>> program in some protection from the user replacing the image with
>>> a bad
>>> >>>> or
>>> >>>> completely wrong
>>> >>>> file.  Any ideas?
>>> >>>>
>>> >>>>
>>> >>>> Lou
>>> >>>> --
>>> >>>> Louis LaBrunda
>>> >>>> Keystone Software Corp.
>>> >>>> SkypeMe callto://PhotonDemon
>>> >>>>
>>> >>>>
>>> >>>>
>>> >>>
>>> >>>
>>> >>>
>>> >> --
>>> >> Louis LaBrunda
>>> >> Keystone Software Corp.
>>> >> SkypeMe callto://PhotonDemon
>>> >>
>>> >>
>>> >>
>>> >
>>> >
>>> >
>>> --
>>> Louis LaBrunda
>>> Keystone Software Corp.
>>> SkypeMe callto://PhotonDemon
>>>
>>>
>>
> --
> Louis LaBrunda
> Keystone Software Corp.
> SkypeMe callto://PhotonDemon
>
>
>



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can a running Squeak program look at a Squeak image file and know if it is a good image?

Louis LaBrunda
Thanks Dave, I got it now.  Don't beat yourself up, I appreciate the help even if it is slow in
coming.  After all, beggars can't be choosers.  Hopefully one last question.  Is there some
method or methods, I can send the running image and the image file that allow me to conclude
they are close in nature?

Lou


On Tue, 25 Jul 2017 15:06:49 -0400 (EDT), "David T. Lewis" <[hidden email]> wrote:

>Lou,
>
>So sorry, I think I need a new brain today. The repository is on
>source.squeak.org, not on squeaksource.com as I said in my earlier mail.
>The stuff on squeaksource.com is ancient, and all recent VM related work
>was moved to source.squeak.org a long time ago.
>
>My apologies again!
>
>Dave
>
>> Hey Dave,
>>
>> I'm sure I'm messing something up but I can't find ImageFormat-dtl.26,
>> they only go up to
>> ImageFormat-dtl.12.  Am I looking in the wrong place?
>>
>> Lou
>>
>>
>> On Tue, 25 Jul 2017 14:06:30 -0400, "David T. Lewis" <[hidden email]>
>> wrote:
>>
>>>I guess I just forgot to upload it from my package-cache. Please try
>>> again
>>>with the ImageFormat-dtl.26 that I just uploaded, it should work now.
>>> Sorry
>>>for the confusion.
>>>
>>>Dave
>>>
>>>
>>>On Tue, Jul 25, 2017 at 01:54:43PM -0400, Louis LaBrunda wrote:
>>>> Hi Dave,
>>>>
>>>> Thanks Dave.  I will check tomorrow.  For now I will assume it will get
>>>> fixed and work around
>>>> it.
>>>>
>>>> Lou
>>>>
>>>> On Tue, 25 Jul 2017 13:47:12 -0400 (EDT), "David T. Lewis"
>>>> <[hidden email]> wrote:
>>>>
>>>> >Hi Lou,
>>>> >
>>>> >Ugh, I think that was due to a bug that I fixed not too long ago (some
>>>> >missing methods for the latest Spur formats IIRC). I thought I had
>>>> >uploaded the fix but I do not see it in the repository. My apologies,
>>>> I
>>>> >will address it as quickly as I can, but it might not be until
>>>> tomorrow.
>>>> >
>>>> >Sorry,
>>>> >Dave
>>>> >
>>>> >
>>>> >> Hi Dave,
>>>> >>
>>>> >> Thanks you very much for the prompt reply.  I loaded the ImageFormat
>>>> >> package as you suggested
>>>> >> into a fairly new 32 bit image.  But when I try ImageFormat
>>>> fromFile: to
>>>> >> that image of the
>>>> >> image with my program, I get an "unrecognized image format" error.
>>>> I will
>>>> >> keep trying more
>>>> >> after lunch but for now I don't get it?
>>>> >>
>>>> >> Lou
>>>> >>
>>>> >>
>>>> >> On Tue, 25 Jul 2017 11:18:05 -0400 (EDT), "David T. Lewis"
>>>> >> <[hidden email]> wrote:
>>>> >>
>>>> >>>Hi Lou,
>>>> >>>
>>>> >>>A simple check is to look at the first bytes of the image file,
>>>> which
>>>> >>>define the image format number. If the image format is something
>>>> >>>reasonable (presumably the same as whatever image you are replacing
>>>> in
>>>> >>>most cases), then you know that it is a Squeak image file, although
>>>> this
>>>> >>>will not tell you if the actual image is valid.
>>>> >>>
>>>> >>>To do this from a running Squeak image, try loading the ImageFormat
>>>> >>>package from the VMMaker repository on squeaksource.com. Look at the
>>>> >>> class
>>>> >>>comments, and you will find methods for reading the image format
>>>> number
>>>> >>>from a file stream.
>>>> >>>
>>>> >>>There is also a C program called ckformat.c at
>>>> >>>http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/src/. The C code
>>>> is
>>>> >>>automatically generated from the ImageFormat package, so they the do
>>>> the
>>>> >>>same thing. If you want to do the test from a shell script, as
>>>> opposed to
>>>> >>>doing it from the running image, then you can use this C program.
>>>> >>>
>>>> >>>Of course in theory you can load an entire image file into a VM
>>>> simulator
>>>> >>>with the VMMaker package, but that would not be a practical test for
>>>> what
>>>> >>>you are trying to accomplish.
>>>> >>>
>>>> >>>If you need a better test of "valid" then you might consider using
>>>> >>>OSProcess/CommandShell to actually run the image file and see if it
>>>> >>> works.
>>>> >>>Probably you would do something like run it with a PipeableOSProcess
>>>> >>>connected to your main Squeak image, and just kill the image under
>>>> test
>>>> >>>once you have confirmed that it runs.
>>>> >>>
>>>> >>>Dave
>>>> >>>
>>>> >>>> Hi All,
>>>> >>>>
>>>> >>>> Can a running Squeak program look at a Squeak image file and know
>>>> if it
>>>> >>>> is
>>>> >>>> a good image?  I'm
>>>> >>>> working on a program that the user won't have easy access to.  I
>>>> would
>>>> >>>> like to allow its
>>>> >>>> replacement with a new version.  I think I know how to do that but
>>>> >>>> would
>>>> >>>> like to see if I can
>>>> >>>> program in some protection from the user replacing the image with
>>>> a bad
>>>> >>>> or
>>>> >>>> completely wrong
>>>> >>>> file.  Any ideas?
>>>> >>>>
>>>> >>>>
>>>> >>>> Lou
>>>> >>>> --
>>>> >>>> Louis LaBrunda
>>>> >>>> Keystone Software Corp.
>>>> >>>> SkypeMe callto://PhotonDemon
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> >>>
>>>> >>>
>>>> >>>
>>>> >> --
>>>> >> Louis LaBrunda
>>>> >> Keystone Software Corp.
>>>> >> SkypeMe callto://PhotonDemon
>>>> >>
>>>> >>
>>>> >>
>>>> >
>>>> >
>>>> >
>>>> --
>>>> Louis LaBrunda
>>>> Keystone Software Corp.
>>>> SkypeMe callto://PhotonDemon
>>>>
>>>>
>>>
>> --
>> Louis LaBrunda
>> Keystone Software Corp.
>> SkypeMe callto://PhotonDemon
>>
>>
>>
>
>
>
--
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can a running Squeak program look at a Squeak image file and know if it is a good image?

Bert Freudenberg
We don't have a meaningful "diff" between images. You could compare the list of package versions etc. but it's not foolproof as there might be modifications outside the packages.

Maybe it would help if you gave us a broader picture - are you just trying to update an application with a new image? That is, do you control what the new image is, or are users supposed to upload their own / arbitrary images?

If you control the image then I would simply do a checksum and verify that before replacing.

- Bert -

On Tue, Jul 25, 2017 at 9:24 PM, Louis LaBrunda <[hidden email]> wrote:
Thanks Dave, I got it now.  Don't beat yourself up, I appreciate the help even if it is slow in
coming.  After all, beggars can't be choosers.  Hopefully one last question.  Is there some
method or methods, I can send the running image and the image file that allow me to conclude
they are close in nature?

Lou


On Tue, 25 Jul 2017 15:06:49 -0400 (EDT), "David T. Lewis" <[hidden email]> wrote:

>Lou,
>
>So sorry, I think I need a new brain today. The repository is on
>source.squeak.org, not on squeaksource.com as I said in my earlier mail.
>The stuff on squeaksource.com is ancient, and all recent VM related work
>was moved to source.squeak.org a long time ago.
>
>My apologies again!
>
>Dave
>
>> Hey Dave,
>>
>> I'm sure I'm messing something up but I can't find ImageFormat-dtl.26,
>> they only go up to
>> ImageFormat-dtl.12.  Am I looking in the wrong place?
>>
>> Lou
>>
>>
>> On Tue, 25 Jul 2017 14:06:30 -0400, "David T. Lewis" <[hidden email]>
>> wrote:
>>
>>>I guess I just forgot to upload it from my package-cache. Please try
>>> again
>>>with the ImageFormat-dtl.26 that I just uploaded, it should work now.
>>> Sorry
>>>for the confusion.
>>>
>>>Dave
>>>
>>>
>>>On Tue, Jul 25, 2017 at 01:54:43PM -0400, Louis LaBrunda wrote:
>>>> Hi Dave,
>>>>
>>>> Thanks Dave.  I will check tomorrow.  For now I will assume it will get
>>>> fixed and work around
>>>> it.
>>>>
>>>> Lou
>>>>
>>>> On Tue, 25 Jul 2017 13:47:12 -0400 (EDT), "David T. Lewis"
>>>> <[hidden email]> wrote:
>>>>
>>>> >Hi Lou,
>>>> >
>>>> >Ugh, I think that was due to a bug that I fixed not too long ago (some
>>>> >missing methods for the latest Spur formats IIRC). I thought I had
>>>> >uploaded the fix but I do not see it in the repository. My apologies,
>>>> I
>>>> >will address it as quickly as I can, but it might not be until
>>>> tomorrow.
>>>> >
>>>> >Sorry,
>>>> >Dave
>>>> >
>>>> >
>>>> >> Hi Dave,
>>>> >>
>>>> >> Thanks you very much for the prompt reply.  I loaded the ImageFormat
>>>> >> package as you suggested
>>>> >> into a fairly new 32 bit image.  But when I try ImageFormat
>>>> fromFile: to
>>>> >> that image of the
>>>> >> image with my program, I get an "unrecognized image format" error.
>>>> I will
>>>> >> keep trying more
>>>> >> after lunch but for now I don't get it?
>>>> >>
>>>> >> Lou
>>>> >>
>>>> >>
>>>> >> On Tue, 25 Jul 2017 11:18:05 -0400 (EDT), "David T. Lewis"
>>>> >> <[hidden email]> wrote:
>>>> >>
>>>> >>>Hi Lou,
>>>> >>>
>>>> >>>A simple check is to look at the first bytes of the image file,
>>>> which
>>>> >>>define the image format number. If the image format is something
>>>> >>>reasonable (presumably the same as whatever image you are replacing
>>>> in
>>>> >>>most cases), then you know that it is a Squeak image file, although
>>>> this
>>>> >>>will not tell you if the actual image is valid.
>>>> >>>
>>>> >>>To do this from a running Squeak image, try loading the ImageFormat
>>>> >>>package from the VMMaker repository on squeaksource.com. Look at the
>>>> >>> class
>>>> >>>comments, and you will find methods for reading the image format
>>>> number
>>>> >>>from a file stream.
>>>> >>>
>>>> >>>There is also a C program called ckformat.c at
>>>> >>>http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/src/. The C code
>>>> is
>>>> >>>automatically generated from the ImageFormat package, so they the do
>>>> the
>>>> >>>same thing. If you want to do the test from a shell script, as
>>>> opposed to
>>>> >>>doing it from the running image, then you can use this C program.
>>>> >>>
>>>> >>>Of course in theory you can load an entire image file into a VM
>>>> simulator
>>>> >>>with the VMMaker package, but that would not be a practical test for
>>>> what
>>>> >>>you are trying to accomplish.
>>>> >>>
>>>> >>>If you need a better test of "valid" then you might consider using
>>>> >>>OSProcess/CommandShell to actually run the image file and see if it
>>>> >>> works.
>>>> >>>Probably you would do something like run it with a PipeableOSProcess
>>>> >>>connected to your main Squeak image, and just kill the image under
>>>> test
>>>> >>>once you have confirmed that it runs.
>>>> >>>
>>>> >>>Dave
>>>> >>>
>>>> >>>> Hi All,
>>>> >>>>
>>>> >>>> Can a running Squeak program look at a Squeak image file and know
>>>> if it
>>>> >>>> is
>>>> >>>> a good image?  I'm
>>>> >>>> working on a program that the user won't have easy access to.  I
>>>> would
>>>> >>>> like to allow its
>>>> >>>> replacement with a new version.  I think I know how to do that but
>>>> >>>> would
>>>> >>>> like to see if I can
>>>> >>>> program in some protection from the user replacing the image with
>>>> a bad
>>>> >>>> or
>>>> >>>> completely wrong
>>>> >>>> file.  Any ideas?
>>>> >>>>
>>>> >>>>
>>>> >>>> Lou
>>>> >>>> --
>>>> >>>> Louis LaBrunda
>>>> >>>> Keystone Software Corp.
>>>> >>>> SkypeMe callto://PhotonDemon
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> >>>
>>>> >>>
>>>> >>>
>>>> >> --
>>>> >> Louis LaBrunda
>>>> >> Keystone Software Corp.
>>>> >> SkypeMe callto://PhotonDemon
>>>> >>
>>>> >>
>>>> >>
>>>> >
>>>> >
>>>> >
>>>> --
>>>> Louis LaBrunda
>>>> Keystone Software Corp.
>>>> SkypeMe callto://PhotonDemon
>>>>
>>>>
>>>
>> --
>> Louis LaBrunda
>> Keystone Software Corp.
>> SkypeMe callto://PhotonDemon
>>
>>
>>
>
>
>
--
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon





Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can a running Squeak program look at a Squeak image file and know if it is a good image?

Louis LaBrunda
Hi Bert,

Thanks for the help.  I control the image.  I would make a new version available.

The program runs headless on a Raspberry Pi.  The user interfaces with it via a web browser.
The system is a Seaside program that allows the user to control the GPIO pins from a web
browser.  Normally there wouldn't be a mouse or keyboard.  The user wouldn't know where to put
a new copy of the program.

The program would allow the user to do a file upload.  I want to make a small number of checks
of the new uploaded program before replacing the existing image.  I want to protect the user
from dumb mistakes like pointing the file upload to the wrong file.  If the user points to a
Squeak image that isn't the real program, they are on their own.  That can be fixed but the
program would no longer be able to help.

I don't know if a checksum would work as I don't know what the current program would be able to
compare the checksum to.  Unless I were able to append it to the end of the file or something
like that.

Thanks again for any ideas.

Lou

On Tue, 25 Jul 2017 21:31:00 +0200, Bert Freudenberg <[hidden email]> wrote:

>We don't have a meaningful "diff" between images. You could compare the
>list of package versions etc. but it's not foolproof as there might be
>modifications outside the packages.
>
>Maybe it would help if you gave us a broader picture - are you just trying
>to update an application with a new image? That is, do you control what the
>new image is, or are users supposed to upload their own / arbitrary images?
>
>If you control the image then I would simply do a checksum and verify that
>before replacing.
>
>- Bert -
>
>On Tue, Jul 25, 2017 at 9:24 PM, Louis LaBrunda <[hidden email]>
>wrote:
>
>> Thanks Dave, I got it now.  Don't beat yourself up, I appreciate the help
>> even if it is slow in
>> coming.  After all, beggars can't be choosers.  Hopefully one last
>> question.  Is there some
>> method or methods, I can send the running image and the image file that
>> allow me to conclude
>> they are close in nature?
>>
>> Lou
>>
>>
>> On Tue, 25 Jul 2017 15:06:49 -0400 (EDT), "David T. Lewis" <
>> [hidden email]> wrote:
>>
>> >Lou,
>> >
>> >So sorry, I think I need a new brain today. The repository is on
>> >source.squeak.org, not on squeaksource.com as I said in my earlier mail.
>> >The stuff on squeaksource.com is ancient, and all recent VM related work
>> >was moved to source.squeak.org a long time ago.
>> >
>> >My apologies again!
>> >
>> >Dave
>> >
>> >> Hey Dave,
>> >>
>> >> I'm sure I'm messing something up but I can't find ImageFormat-dtl.26,
>> >> they only go up to
>> >> ImageFormat-dtl.12.  Am I looking in the wrong place?
>> >>
>> >> Lou
>> >>
>> >>
>> >> On Tue, 25 Jul 2017 14:06:30 -0400, "David T. Lewis" <
>> [hidden email]>
>> >> wrote:
>> >>
>> >>>I guess I just forgot to upload it from my package-cache. Please try
>> >>> again
>> >>>with the ImageFormat-dtl.26 that I just uploaded, it should work now.
>> >>> Sorry
>> >>>for the confusion.
>> >>>
>> >>>Dave
>> >>>
>> >>>
>> >>>On Tue, Jul 25, 2017 at 01:54:43PM -0400, Louis LaBrunda wrote:
>> >>>> Hi Dave,
>> >>>>
>> >>>> Thanks Dave.  I will check tomorrow.  For now I will assume it will
>> get
>> >>>> fixed and work around
>> >>>> it.
>> >>>>
>> >>>> Lou
>> >>>>
>> >>>> On Tue, 25 Jul 2017 13:47:12 -0400 (EDT), "David T. Lewis"
>> >>>> <[hidden email]> wrote:
>> >>>>
>> >>>> >Hi Lou,
>> >>>> >
>> >>>> >Ugh, I think that was due to a bug that I fixed not too long ago
>> (some
>> >>>> >missing methods for the latest Spur formats IIRC). I thought I had
>> >>>> >uploaded the fix but I do not see it in the repository. My apologies,
>> >>>> I
>> >>>> >will address it as quickly as I can, but it might not be until
>> >>>> tomorrow.
>> >>>> >
>> >>>> >Sorry,
>> >>>> >Dave
>> >>>> >
>> >>>> >
>> >>>> >> Hi Dave,
>> >>>> >>
>> >>>> >> Thanks you very much for the prompt reply.  I loaded the
>> ImageFormat
>> >>>> >> package as you suggested
>> >>>> >> into a fairly new 32 bit image.  But when I try ImageFormat
>> >>>> fromFile: to
>> >>>> >> that image of the
>> >>>> >> image with my program, I get an "unrecognized image format" error.
>> >>>> I will
>> >>>> >> keep trying more
>> >>>> >> after lunch but for now I don't get it?
>> >>>> >>
>> >>>> >> Lou
>> >>>> >>
>> >>>> >>
>> >>>> >> On Tue, 25 Jul 2017 11:18:05 -0400 (EDT), "David T. Lewis"
>> >>>> >> <[hidden email]> wrote:
>> >>>> >>
>> >>>> >>>Hi Lou,
>> >>>> >>>
>> >>>> >>>A simple check is to look at the first bytes of the image file,
>> >>>> which
>> >>>> >>>define the image format number. If the image format is something
>> >>>> >>>reasonable (presumably the same as whatever image you are replacing
>> >>>> in
>> >>>> >>>most cases), then you know that it is a Squeak image file, although
>> >>>> this
>> >>>> >>>will not tell you if the actual image is valid.
>> >>>> >>>
>> >>>> >>>To do this from a running Squeak image, try loading the ImageFormat
>> >>>> >>>package from the VMMaker repository on squeaksource.com. Look at
>> the
>> >>>> >>> class
>> >>>> >>>comments, and you will find methods for reading the image format
>> >>>> number
>> >>>> >>>from a file stream.
>> >>>> >>>
>> >>>> >>>There is also a C program called ckformat.c at
>> >>>> >>>http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/src/. The C
>> code
>> >>>> is
>> >>>> >>>automatically generated from the ImageFormat package, so they the
>> do
>> >>>> the
>> >>>> >>>same thing. If you want to do the test from a shell script, as
>> >>>> opposed to
>> >>>> >>>doing it from the running image, then you can use this C program.
>> >>>> >>>
>> >>>> >>>Of course in theory you can load an entire image file into a VM
>> >>>> simulator
>> >>>> >>>with the VMMaker package, but that would not be a practical test
>> for
>> >>>> what
>> >>>> >>>you are trying to accomplish.
>> >>>> >>>
>> >>>> >>>If you need a better test of "valid" then you might consider using
>> >>>> >>>OSProcess/CommandShell to actually run the image file and see if it
>> >>>> >>> works.
>> >>>> >>>Probably you would do something like run it with a
>> PipeableOSProcess
>> >>>> >>>connected to your main Squeak image, and just kill the image under
>> >>>> test
>> >>>> >>>once you have confirmed that it runs.
>> >>>> >>>
>> >>>> >>>Dave
>> >>>> >>>
>> >>>> >>>> Hi All,
>> >>>> >>>>
>> >>>> >>>> Can a running Squeak program look at a Squeak image file and know
>> >>>> if it
>> >>>> >>>> is
>> >>>> >>>> a good image?  I'm
>> >>>> >>>> working on a program that the user won't have easy access to.  I
>> >>>> would
>> >>>> >>>> like to allow its
>> >>>> >>>> replacement with a new version.  I think I know how to do that
>> but
>> >>>> >>>> would
>> >>>> >>>> like to see if I can
>> >>>> >>>> program in some protection from the user replacing the image with
>> >>>> a bad
>> >>>> >>>> or
>> >>>> >>>> completely wrong
>> >>>> >>>> file.  Any ideas?
>> >>>> >>>>
>> >>>> >>>>
>> >>>> >>>> Lou
>> >>>> >>>> --
>> >>>> >>>> Louis LaBrunda
>> >>>> >>>> Keystone Software Corp.
>> >>>> >>>> SkypeMe callto://PhotonDemon
>> >>>> >>>>
>> >>>> >>>>
>> >>>> >>>>
>> >>>> >>>
>> >>>> >>>
>> >>>> >>>
>> >>>> >> --
>> >>>> >> Louis LaBrunda
>> >>>> >> Keystone Software Corp.
>> >>>> >> SkypeMe callto://PhotonDemon
>> >>>> >>
>> >>>> >>
>> >>>> >>
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> --
>> >>>> Louis LaBrunda
>> >>>> Keystone Software Corp.
>> >>>> SkypeMe callto://PhotonDemon
>> >>>>
>> >>>>
>> >>>
>> >> --
>> >> Louis LaBrunda
>> >> Keystone Software Corp.
>> >> SkypeMe callto://PhotonDemon
>> >>
>> >>
>> >>
>> >
>> >
>> >
>> --
>> Louis LaBrunda
>> Keystone Software Corp.
>> SkypeMe callto://PhotonDemon
>>
>>
>>
--
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can a running Squeak program look at a Squeak image file and know if it is a good image?

Louis LaBrunda
In reply to this post by timrowledge
Hi Tim,

I like the zip idea.  Thanks.  Can you please point me to a class that will un-zip a byte array
or stream.

Lou


On Tue, 25 Jul 2017 10:01:04 -0700, tim Rowledge <[hidden email]> wrote:

>Don’t forget to start off by checking the file size and some variety of hash - MD5 seems to be a common utility. And zip the file(s) when ending both for the obvious speed reason and as another sort of integrity check.
>
>Or, consider not sending entire images, but using an update stream private to your project. Hell, you could even use my MQTTClient thing to subscribe to an update topic...
>
>tim
--
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon


cbc
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can a running Squeak program look at a Squeak image file and know if it is a good image?

cbc
ZipArchive is probably your friend here.  Let's you do full zip file usage.
Note that this both encodes and decodes.

If you really want to deal with individual arrays in some other format, look at the DeflateStream (and InflateStream).  But I'd suggest working with ZipArchive first until it doesn't suite your needs.

-cbc

On Wed, Jul 26, 2017 at 7:10 AM, Louis LaBrunda <[hidden email]> wrote:
Hi Tim,

I like the zip idea.  Thanks.  Can you please point me to a class that will un-zip a byte array
or stream.

Lou


On Tue, 25 Jul 2017 10:01:04 -0700, tim Rowledge <[hidden email]> wrote:

>Don’t forget to start off by checking the file size and some variety of hash - MD5 seems to be a common utility. And zip the file(s) when ending both for the obvious speed reason and as another sort of integrity check.
>
>Or, consider not sending entire images, but using an update stream private to your project. Hell, you could even use my MQTTClient thing to subscribe to an update topic...
>
>tim
--
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon





Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can a running Squeak program look at a Squeak image file and know if it is a good image?

timrowledge
In reply to this post by Louis LaBrunda

> On 25-07-2017, at 1:21 PM, Louis LaBrunda <[hidden email]> wrote:
>
> I don't know if a checksum would work as I don't know what the current program would be able to
> compare the checksum to.  Unless I were able to append it to the end of the file or something
> like that.

That’s partly why I would suggest trying a zip file with the image file and a checksum (plus possibly other  data?) in it. If the zip file doesn’t get transmitted properly it shouldn’t open, giving one clue of failure. I if does, you read the expected checksum and unzip the putative image file to compare it with.

I’m still inclined to think that private update stream approach would be easier to live with.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
"Bollocks," said Pooh being more forthright than usual



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can a running Squeak program look at a Squeak image file and know if it is a good image?

Louis LaBrunda
In reply to this post by Bert Freudenberg
Hi Bert, Tim and Dave,

Thanks for the help.  I am now able to replace a running image on the fly.  I allow the user to
do a file upload (this is a Seaside program interfacing with a web browser).  The file can be a
new image (should be supplied by me) or a zip (file type must be .zip) of the same file.  The
running image is never saved so the changes file is not needed.

I check that the file is a valid image and if it is, I replace the running image and reboot the
system, which will restart with the new image.

Lou
--
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can a running Squeak program look at a Squeak image file and know if it is a good image?

Louis LaBrunda
In reply to this post by timrowledge
Hi Tim,

On Wed, 26 Jul 2017 12:58:03 -0700, tim Rowledge <[hidden email]> wrote:

>
>> On 25-07-2017, at 1:21 PM, Louis LaBrunda <[hidden email]> wrote:
>>
>> I don't know if a checksum would work as I don't know what the current program would be able to
>> compare the checksum to.  Unless I were able to append it to the end of the file or something
>> like that.
>
>That’s partly why I would suggest trying a zip file with the image file and a checksum (plus possibly other  data?) in it. If the zip file doesn’t get transmitted properly it shouldn’t open, giving one clue of failure. I if does, you read the expected checksum and unzip the putative image file to compare it with.

Adding the checksum in a small file in the zip file could be worth it.

>I’m still inclined to think that private update stream approach would be easier to live with.

I'm not sure as to exactly what you are suggesting here but don't forget the program is running
on a Raspberry Pi that may not be connected to the internet.  The user is expected to obtain a
new image onto some other computer and then upload it to the Raspberry Pi via the programs
Seaside web interface.

Lou
--
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon


Loading...