cupsFileRead & cupsFileWrite shouldn't return an error for 0 bytes #985

Closed
michaelrsweet opened this Issue Oct 27, 2004 · 4 comments

Comments

Projects
None yet
1 participant
Collaborator

michaelrsweet commented Oct 27, 2004

Version: 1.1-current
CUPS.org User: jlovell

cupsFileRead & cupsFileWrite shouldn't return an error when asked to read or write 0 bytes. Attached patch fixes it.

Thanks!

Collaborator

michaelrsweet commented Oct 28, 2004

CUPS.org User: mike

Note: I modified your patch after reviewing it - 0-length read/write should return 0 immediately...

Collaborator

michaelrsweet commented Oct 28, 2004

CUPS.org User: mike

Fixed in CVS - the anonymous CVS repository will be updated at midnight EST.

Collaborator

michaelrsweet commented Oct 28, 2004

"file.diff":

Index: file.c

RCS file: /home/anoncvs/cups/scheduler/file.c,v
retrieving revision 1.10
diff -u -d -b -w -r1.10 file.c
--- file.c 4 Oct 2004 19:40:35 -0000 1.10
+++ file.c 27 Oct 2004 17:44:23 -0000
@@ -458,7 +458,7 @@

  • Range check input...
    */
  • if (!fp || !buf || bytes <= 0 || fp->mode != 'r')
  • if (!fp || !buf || bytes < 0 || fp->mode != 'r')
    return (-1);

/*
@@ -620,7 +620,7 @@

  • Range check input...
    */
  • if (!fp || !buf || bytes <= 0 || fp->mode != 'w')
  • if (!fp || !buf || bytes < 0 || fp->mode != 'w')
    return (-1);

/*

Collaborator

michaelrsweet commented Oct 28, 2004

"str985.patch":

Index: file.c

RCS file: /development/cvs/cups/scheduler/file.c,v
retrieving revision 1.10
diff -u -r1.10 file.c
--- file.c 4 Oct 2004 19:40:35 -0000 1.10
+++ file.c 28 Oct 2004 16:11:36 -0000
@@ -458,9 +458,12 @@

  • Range check input...
    */
  • if (!fp || !buf || bytes <= 0 || fp->mode != 'r')
  • if (!fp || !buf || bytes < 0 || fp->mode != 'r')
    return (-1);
  • if (bytes == 0)
  • return (0);

/*

  • Loop until all bytes are read...
    */
    @@ -620,8 +623,11 @@
  • Range check input...
    */
  • if (!fp || !buf || bytes <= 0 || fp->mode != 'w')
  • if (!fp || !buf || bytes < 0 || fp->mode != 'w')
    return (-1);
  • if (bytes == 0)
  • return (0);

/*

  • Write the buffer...

@michaelrsweet michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment