mirror of https://github.com/MidnightCommander/mc
* man2hlp.c (persistent_fread): Return error for len <= 0.
(persistent_fwrite): Likewise. (main): Check the result of the second ftell().
This commit is contained in:
parent
4af124c573
commit
895c9468c3
|
@ -1,5 +1,9 @@
|
|||
2002-11-13 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* man2hlp.c (persistent_fread): Return error for len <= 0.
|
||||
(persistent_fwrite): Likewise.
|
||||
(main): Check the result of the second ftell().
|
||||
|
||||
* cmd.h: Fully exclude WPanel from public interfaces of cmd.c.
|
||||
* cmd.c: All commands operate on current panels.
|
||||
(get_a_panel): Remove.
|
||||
|
|
|
@ -74,6 +74,9 @@ persistent_fread (void *data, size_t len, FILE *stream)
|
|||
size_t bytes_done = 0;
|
||||
char *ptr = (char *) data;
|
||||
|
||||
if (len <= 0)
|
||||
return 0;
|
||||
|
||||
while (bytes_done < len) {
|
||||
count = len - bytes_done;
|
||||
if (count > MAX_STREAM_BLOCK)
|
||||
|
@ -102,6 +105,9 @@ persistent_fwrite (const void *data, size_t len, FILE *stream)
|
|||
size_t bytes_done = 0;
|
||||
const char *ptr = (const char *) data;
|
||||
|
||||
if (len <= 0)
|
||||
return 0;
|
||||
|
||||
while (bytes_done < len) {
|
||||
count = len - bytes_done;
|
||||
if (count > MAX_STREAM_BLOCK)
|
||||
|
@ -780,6 +786,11 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
cont_start = ftell (f_out);
|
||||
if (cont_start <= 0) {
|
||||
perror (c_out);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (topics)
|
||||
fprintf (f_out, "\004[Contents]\n%s\n\n", topics);
|
||||
else
|
||||
|
@ -830,7 +841,9 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
file_end = ftell (f_out);
|
||||
if (file_end <= 0) {
|
||||
|
||||
/* Sanity check */
|
||||
if ((file_end <= 0) || (file_end - cont_start <= 0)) {
|
||||
perror (c_out);
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue