Bug Tracker item #2820558, was opened at 2009-07-12 17:47
Message generated for change (Comment added) made by deantakemori
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1126467&aid=2820558&group_id=250683

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: daemon
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Dean Takemori (deantakemori)
Assigned to: Stevan Bajic (sbajic)
Summary: Another hash_drv bug

Initial Comment:
in _ds_get_signature():

  if (fread(SIG->data, statbuf.st_size, 1, file) != statbuf.st_size) {

But man fread says:
       fread() and fwrite() return the number of items  successfully  read  or
       written  (i.e.,  not the number of characters).  If an error occurs, or
       the end-of-file is reached, the return value is a short item count  (or
       zero).

so the test should be < 1

----------------------------------------------------------------------

>Comment By: Dean Takemori (deantakemori)
Date: 2009-07-13 16:18

Message:
Sorry.  I confused this bug with another that I am still tracking down in
csscompress.

my documentation says fread returns the number of items read on success,
not the size.  Without the change I indicated, trying to train dspam on
error gives the following in the logs

Unable to find a valid signature. Aborting.


----------------------------------------------------------------------

Comment By: Stevan Bajic (sbajic)
Date: 2009-07-13 15:54

Message:
Hallo Dean

You are funny. 

> RETURN THE NUMBER IF ITEMS successfully read
> or written (i.e., NOT THE NUMBER OF CHARACTERS).
>
And what do you think influences the size of items? The 3th parameter. So
if you set it to 1 then it will return the number of bytes read/written. If
you set it to 2 then it will return 2 * (number of bytes) +/- 1

Anyway... I have to look at that issue. You are jumping up and down, left
and right. Your original bug was about _ds_get_signature() and now you
start to write about csscompress. So what now? Where do you have an issue?

Kind Regards

Stevan Bajic

----------------------------------------------------------------------

Comment By: Dean Takemori (deantakemori)
Date: 2009-07-13 15:30

Message:
My system man pages (man 3 fread) say:

       size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);

      The function fread() reads nmemb elements  of  data,  each  size 
bytes
       long,  from  the stream pointed to by stream, storing them at the
loca-
       tion given by ptr.

       fread() and fwrite() RETURN THE NUMBER IF ITEMS  successfully  read
 or
       written  (i.e.,  NOT THE NUMBER OF CHARACTERS).  If an error
occurs, or
       the end-of-file is reached, the return value is a short item count 
(or
       zero).

Which I read as saying fread returns the number of ITEMS (elements)
successfully read, NOT the number of BYTES.  Note: read (without the "f"
returns the number of bytes)

This seems to be verified by csscompress, which fails for me unless I make
the change to "< 1"

----------------------------------------------------------------------

Comment By: Stevan Bajic (sbajic)
Date: 2009-07-13 13:28

Message:
Hallo Dean

The 3th parameter for fread is used as count. So if statbuf.st_size * 1 is
not equal to the return value of fread then the file was not read
completely. statbuf.st_size is computed by using the stat syscall. Assuming
the file read by fread has 1024 bytes then fread should return 1024 as
result and 1024 * 1 = 1024 and every thing is fine. If fread returns -1 or
any other number not being 1024 then the fread was not successful and DSPAM
will bark about it. So how is that logic supposed to be wrong? Can you post
some examples where that if condition is triggering a bug?


Kind Regards

Stevan Bajic

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1126467&aid=2820558&group_id=250683

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Dspam-devel mailing list
Dspam-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspam-devel

Reply via email to