unstr (package fortune-mod) incorrectly reads data file
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
fortune-mod (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
How to reproduce :
$ strfile fort
"fort.dat" created
There were 36 strings
Longest string: 201 bytes
Shortest string: 25 bytes
$ ls -l fort*
-rw-rw-r-- 1 br br 3383 Feb 23 10:31 fort
-rw-rw-r-- 1 br br 172 Feb 23 10:31 fort.dat
$ unstr fort
Input file: fort
unstr: data file corrupted
The bug is line 234 of unstr.c (source file: https:/
The current checked_fread() macro compares fread() return value with the number of bytes to read :
#define checked_fread(item, size) \
if (fread(item, size, 1, Dataf) != size) \
{ \
exit(1); \
}
It should instead compare fread() return value with the number of items to read, which is 1 :
#define checked_fread(item, size) \
if (fread(item, size, 1, Dataf) != 1) \
{ \
exit(1); \
}
After changing the code, running the same commands give :
$ strfile fort
"fort.dat" created
There were 36 strings
Longest string: 201 bytes
Shortest string: 25 bytes
$ ls -l fort*
-rw-rw-r-- 1 br br 3383 Feb 23 10:31 fort
-rw-rw-r-- 1 br br 172 Feb 23 10:38 fort.dat
$ ./unstr fort
Input file: fort
nothing to do -- table in file order
The attachment "unstr.c: fix fread() return value test" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.
[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]