[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6801] try to create a dir file if it's empty; allocate extra byte for s
From: |
Gavin D. Smith |
Subject: |
[6801] try to create a dir file if it's empty; allocate extra byte for strncat |
Date: |
Sun, 22 Nov 2015 20:50:08 +0000 |
Revision: 6801
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6801
Author: gavin
Date: 2015-11-22 20:50:06 +0000 (Sun, 22 Nov 2015)
Log Message:
-----------
try to create a dir file if it's empty; allocate extra byte for strncat
Modified Paths:
--------------
trunk/ChangeLog
trunk/install-info/install-info.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2015-11-22 16:30:30 UTC (rev 6800)
+++ trunk/ChangeLog 2015-11-22 20:50:06 UTC (rev 6801)
@@ -1,5 +1,15 @@
2015-11-22 Gavin Smith <address@hidden>
+ * install-info/install-info.c (open_possibly_compressed_file):
+ If file is empty, try to create it if passed a callback for
+ doing so. Problem with zero-sized dir files reported by
+ Pedrum Mohageri.
+ (format_entry): Use xmalloc instead of malloc. Allocate an
+ extra byte. Crash with strncat under Mac OS X Yosemite reported
+ by Alan Wehmann.
+
+2015-11-22 Gavin Smith <address@hidden>
+
* info/infodoc.c (info_get_info_help_node): Resort to
"(info-stnd)" if "(info)" isn't found. Look for "(info)"
instead of "(Info)".
Modified: trunk/install-info/install-info.c
===================================================================
--- trunk/install-info/install-info.c 2015-11-22 16:30:30 UTC (rev 6800)
+++ trunk/install-info/install-info.c 2015-11-22 20:50:06 UTC (rev 6801)
@@ -670,6 +670,7 @@
else
close (desc); /* It already existed, so fine. */
}
+
/* Open FILENAME and return the resulting stream pointer. If it doesn't
exist, try FILENAME.gz. If that doesn't exist either, call
@@ -769,11 +770,28 @@
nread = fread (data, sizeof (data), 1, f);
if (nread != 1)
{
- /* Empty files don't set errno. Calling code can check for
- this, so make sure errno == 0 just in case it isn't already. */
if (nread == 0)
- errno = 0;
- return 0;
+ {
+ /* Try to create the file if its empty. */
+ if (feof (f) && create_callback)
+ {
+ if (fclose (f) != 0)
+ return 0; /* unknown error closing file */
+
+ if (remove (filename) != 0)
+ return 0; /* unknown error deleting file */
+
+ (*create_callback) (filename);
+ f = fopen (*opened_filename, FOPEN_RBIN);
+ if (!f)
+ return 0;
+ nread = fread (data, sizeof (data), 1, f);
+ if (nread == 0)
+ return 0;
+ }
+ }
+ errno = 0;
+ return 0; /* unknown error */
}
if (!compression_program)
@@ -1404,9 +1422,8 @@
if (!desc || !name)
return 1;
- outstr = malloc (width +
- (((desc_len + width) / (width - align)) * width) * 2
- * sizeof (char));
+ outstr = xmalloc (width
+ + (desc_len + width) / (width - align) * width * 2 * sizeof (char));
outstr[0] = '\0';
strncat (outstr, name, name_len);
@@ -1444,7 +1461,9 @@
if (offset_out + 1 >= allocated_out)
{
allocated_out = offset_out + 1;
- line_out = (char *) realloc ((void *)line_out, allocated_out);
+ line_out = (char *) xrealloc ((void *)line_out, allocated_out + 1);
+ /* The + 1 here shouldn't be necessary, but a crash was reported
+ for a following strncat call. */
}
if (c == '\n')
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6801] try to create a dir file if it's empty; allocate extra byte for strncat,
Gavin D. Smith <=