[Glibc-bsd-commits] r5926 - in trunk/freebsd-libs/debian: . patches
stevenc-guest at alioth.debian.org
stevenc-guest at alioth.debian.org
Sat Mar 5 22:06:53 UTC 2016
Author: stevenc-guest
Date: 2016-03-05 22:06:53 +0000 (Sat, 05 Mar 2016)
New Revision: 5926
Added:
trunk/freebsd-libs/debian/patches/replace_fgetln.diff
Modified:
trunk/freebsd-libs/debian/changelog
trunk/freebsd-libs/debian/patches/series
Log:
In fparseln, replace fgetln(3) with getline(3) (Closes: #811238)
Modified: trunk/freebsd-libs/debian/changelog
===================================================================
--- trunk/freebsd-libs/debian/changelog 2016-03-05 20:48:33 UTC (rev 5925)
+++ trunk/freebsd-libs/debian/changelog 2016-03-05 22:06:53 UTC (rev 5926)
@@ -3,6 +3,7 @@
* Avoid including kernel headers on non-kfreebsd arches,
sys/ctype.h and machine/stdarg.h in sys/kern/subr_prf.c
- subr_prf.diff
+ * In fparseln, replace fgetln(3) with getline(3) (Closes: #811238)
-- Steven Chamberlain <steven at pyro.eu.org> Sat, 05 Mar 2016 20:17:57 +0000
Added: trunk/freebsd-libs/debian/patches/replace_fgetln.diff
===================================================================
--- trunk/freebsd-libs/debian/patches/replace_fgetln.diff (rev 0)
+++ trunk/freebsd-libs/debian/patches/replace_fgetln.diff 2016-03-05 22:06:53 UTC (rev 5926)
@@ -0,0 +1,69 @@
+Subject: fparseln: replace fgetln(3) with getline(3)
+From: Steven Chamberlain <steven at pyro.eu.org>
+Date: Sat, 05 Mar 2016 22:04:24 +0000
+
+fgetln(3) is available in FreeBSD's libc but not GNU libc. Use the more
+portable getline(3). This returns a malloc()'d buffer, rather than a
+pointer to a (unterminated) C string, so remember to free it.
+
+fparseln(3) returns a different malloc()'d buffer, which the caller is
+supposed to free(), so remember to actually do that in the test program.
+
+--- a/lib/libutil/fparseln.c
++++ b/lib/libutil/fparseln.c
+@@ -80,7 +80,7 @@
+ {
+ static const char dstr[3] = { '\\', '\\', '#' };
+
+- size_t s, len;
++ ssize_t s, ibuflen, len;
+ char *buf;
+ char *ptr, *cp;
+ int cnt;
+@@ -90,7 +90,9 @@
+ _DIAGASSERT(fp != NULL);
+ #endif
+
++ ibuflen = 0;
+ len = 0;
++ ptr = NULL;
+ buf = NULL;
+ cnt = 1;
+
+@@ -112,7 +114,7 @@
+ if (lineno)
+ (*lineno)++;
+
+- if ((ptr = fgetln(fp, &s)) == NULL)
++ if ((s = getline(&ptr, &ibuflen, fp)) < 0)
+ break;
+
+ if (s && com) { /* Check and eliminate comments */
+@@ -151,6 +153,7 @@
+
+ if ((cp = realloc(buf, len + s + 1)) == NULL) {
+ free(buf);
++ free(ptr);
+ return NULL;
+ }
+ buf = cp;
+@@ -159,6 +162,7 @@
+ len += s;
+ buf[len] = '\0';
+ }
++ free(ptr);
+
+ if ((flags & FPARSELN_UNESCALL) != 0 && esc && buf != NULL &&
+ strchr(buf, esc) != NULL) {
+@@ -206,8 +210,10 @@
+
+ line = 0;
+ while ((ptr = fparseln(stdin, &size, &line, NULL,
+- FPARSELN_UNESCALL)) != NULL)
++ FPARSELN_UNESCALL)) != NULL) {
+ printf("line %d (%d) |%s|\n", line, size, ptr);
++ free(ptr);
++ }
+ return 0;
+ }
+
Modified: trunk/freebsd-libs/debian/patches/series
===================================================================
--- trunk/freebsd-libs/debian/patches/series 2016-03-05 20:48:33 UTC (rev 5925)
+++ trunk/freebsd-libs/debian/patches/series 2016-03-05 22:06:53 UTC (rev 5926)
@@ -33,3 +33,4 @@
libusb_set_auto_detach_kernel_driver.diff
pkgconfig_dir.diff
subr_prf.diff
+replace_fgetln.diff
More information about the Glibc-bsd-commits
mailing list