Patch from Luca Tettamanti :

> > > One of our users discovered a bug in the suspend program which may cause
> > > unplanned program termination.

...

> > > Gentoo bug:
> > > https://bugs.gentoo.org/show_bug.cgi?id=238511
> > >
> > > ferret <ferret@explodingferret.com> writes:
> > >> When I first configured and tried s2disk, it seemed to work
> > > (splash
> > >> progress bar and all) up to the point when I would expect it to
> > > power
> > >> off the system. It then prints an S and a newline and then
> > > returns to
> > >> the shell.
> > >>
> > >>	I tracked the problem down to this C code in suspend.c and
> > > resume.c:
> > >>
> > >> 1388:   unsigned int size = sizeof(struct swsusp_header);
> > >> 1389:   unsigned int shift = (resume_offset + 1) * page_size -
> > > size;
> > >>
> > >> Since I was using a swap file, my resume_offset is 528894,
> > > page_size
> > >> is 4096, and size is 28 (I have checked these values by
> > > inserting a
> > >> printf in the above code):

> > The bug and the analisys are correct, but the fix only works for
64bit systems.

...

> > lseek takes an off_t which is a long; the patch works fine on
x86_64,
> > but on plain x86 a long is still 32bit wide so the value passed to
> > lseek is truncated.
> > I believe that the proper fix is to use lseek64.
3 files changed