kopia lustrzana https://gitlab.com/sane-project/backends
If fread returns 0, check for EOF and other errors and return appropriately.
Henning Meier-Geinitz <henning@meier-geinitz.de>DEVEL_2_0_BRANCH-1
rodzic
d1bbdc5910
commit
00c64adfa2
|
@ -40,7 +40,7 @@
|
||||||
whether to permit this exception to apply to your modifications.
|
whether to permit this exception to apply to your modifications.
|
||||||
If you do not wish that, delete this exception notice. */
|
If you do not wish that, delete this exception notice. */
|
||||||
|
|
||||||
#define BUILD 5
|
#define BUILD 6
|
||||||
|
|
||||||
#include "../include/sane/config.h"
|
#include "../include/sane/config.h"
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "../include/sane/sane.h"
|
#include "../include/sane/sane.h"
|
||||||
#include "../include/sane/sanei.h"
|
#include "../include/sane/sanei.h"
|
||||||
|
@ -1179,6 +1180,21 @@ sane_read (SANE_Handle handle, SANE_Byte * data,
|
||||||
/* Suck in as much of the file as possible, since it's already in the
|
/* Suck in as much of the file as possible, since it's already in the
|
||||||
correct format. */
|
correct format. */
|
||||||
len = fread (data, 1, max_length, infile);
|
len = fread (data, 1, max_length, infile);
|
||||||
|
|
||||||
|
if (len == 0)
|
||||||
|
{
|
||||||
|
if (feof (infile))
|
||||||
|
{
|
||||||
|
DBG(2, "sane_read: EOF reached\n");
|
||||||
|
return SANE_STATUS_EOF;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DBG (1, "sane_read: error while reading file (%s)\n",
|
||||||
|
strerror (errno));
|
||||||
|
return SANE_STATUS_IO_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (parms.depth == 8)
|
if (parms.depth == 8)
|
||||||
{
|
{
|
||||||
|
@ -1241,6 +1257,7 @@ sane_read (SANE_Handle handle, SANE_Byte * data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*length = len;
|
*length = len;
|
||||||
|
DBG (2, "sane_read: read %d bytes\n", len);
|
||||||
return SANE_STATUS_GOOD;
|
return SANE_STATUS_GOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
:backend "pnm"
|
:backend "pnm"
|
||||||
:version "1.0.5"
|
:version "1.0.6"
|
||||||
:status :beta
|
:status :beta
|
||||||
:manpage "sane-pnm"
|
:manpage "sane-pnm"
|
||||||
:url "mailto:henning@meier-geinitz.de"
|
:url "mailto:henning@meier-geinitz.de"
|
||||||
|
|
Ładowanie…
Reference in New Issue