[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch #5907] Implement ADD DOCUMENT command.

From: John Darrington
Subject: [patch #5907] Implement ADD DOCUMENT command.
Date: Thu, 03 May 2007 00:15:37 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060607 Debian/1.7.12-1.2

Update of patch #5907 (project pspp):

             Assigned to:                    None => blp                    


Follow-up Comment #2:

> In the documentation, I don't think that the . should be on a separate
line; although that's valid syntax, it's not a style I've commonly seen.


> In cmd_add_documents, please add a period to the end of the error message.


> I don't think the "x / 80" => "DIV_RND_UP (x, 80)" changes are correct. In
each case, if the number of bytes is not a multiple of 80, then rounding up
will cause subsequent code to read beyond the end of the document string.

Consider what happens if x < 80.  In that case x / 80 is zero.  So n_lines
will get the value zero, and when reading the file back, the error on
sys-file-reader.c:671 will occur (as I found out when experimenting).  In
general, I think the n_lines value which gets written by write_documents (in
sys-file-writer.c) should be the number of complete or partial lines.  So I
think DIV_RND_UP is correct. Otherwise the last line will get dropped unless
it happens to be exactly 80 bytes long.

Currently, of course, everything is written through add_document_line which
ensures that the 2nd argument to dict_set_documents is always a multiple of
80 bytes.  However, whilst we're using / and not DIV_RND_UP,
dict_set_documents is unsafe. 

To prevent reading beyond the end of the document string,  I suggest that we
pad it to an 80 byte multiple before calling buf_write.


Reply to this item at:


  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]