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

Bug#1076285: marked as done (schism: Drop using PATH_MAX on non-Windows platforms)



Your message dated Sat, 17 Aug 2024 13:20:47 +0000
with message-id <E1sfJMN-009Irs-T4@fasolo.debian.org>
and subject line Bug#1076285: fixed in schism 2:20240809-1
has caused the Debian Bug report #1076285,
regarding schism: Drop using PATH_MAX on non-Windows platforms
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
1076285: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1076285
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: schism
Version: 2:20240614-1
Tags: patch

The current source have a few artificial path limitations using
PATH_MAX.  In addition to being a latent problem on any unix platforms
where the file system max do not match the hardcoded PATH_MAX, this also
break the build on GNU Hurd.

I just created a patch to drop this limit on non-Windows machines,
submitted upstream as
<URL: https://github.com/schismtracker/schismtracker/pull/493 >, the
patch is attached here as
0001-Drop-use-of-PATH_MAX-on-non-Windows-platforms.patch.  I've also
created a patch relative to the git edition on salsa, attached as
1000-gnu-hurd-path-max.patch.

Please consider including it in Debian.
-- 
Happy hacking
Petter Reinholdtsen
Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 schism (2:20240614-1) unstable; urgency=medium
 .
   * New upstream version 20240614
Author: Dennis Braun <snd@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>
Last-Update: 2024-07-13

Index: schism-salsa/schism/util.c
===================================================================
--- schism-salsa.orig/schism/util.c	2024-07-13 18:14:28.238021045 +0200
+++ schism-salsa/schism/util.c	2024-07-13 18:39:56.626351661 +0200
@@ -617,10 +617,10 @@
 /* 0 = success, !0 = failed (check errno) */
 int make_backup_file(const char *filename, int numbered)
 {
-	char buf[PATH_MAX];
+	int ret = 0;
+	char *buf = malloc(strlen(filename) + 16);
 
-	/* ensure plenty of room to breathe */
-	if (strlen(filename) > PATH_MAX - 16) {
+	if (NULL == buf) {
 		errno = ENAMETOOLONG;
 		return -1;
 	}
@@ -628,16 +628,19 @@
 	if (numbered) {
 		/* If some crazy person needs more than 65536 backup files,
 		   they probably have more serious issues to tend to. */
-		int n = 1, ret;
+		int n = 1;
 		do {
 			sprintf(buf, "%s.%d~", filename, n++);
 			ret = rename_file(filename, buf, 0);
 		} while (ret != 0 && errno == EEXIST && n < 65536);
+		free(buf);
 		return ret;
 	} else {
 		strcpy(buf, filename);
 		strcat(buf, "~");
-		return rename_file(filename, buf, 1);
+		ret = rename_file(filename, buf, 1);
+		free(buf);
+		return ret;
 	}
 }
 
@@ -783,11 +786,22 @@
 	if (_wgetcwd(buf, PATH_MAX) && !charset_iconv((uint8_t*)buf, &buf_utf8, CHARSET_WCHAR_T, CHARSET_UTF8))
 		return (char*)buf_utf8;
 #else
-	char buf[PATH_MAX + 1] = {'\0'};
+	/* Double the buffer size until getcwd() succeed or we run out
+	   of memory.  Not using get_current_dir_name() and
+	   getcwd(NULL, n) to only use methods defined by POSIX. */
+	size_t n = 1024;
+	char *buf = malloc(n);
+	while (buf && NULL == getcwd(buf, n)) {
+		n *= 2;
+		char *newbuf = realloc(buf, n);
+		if (NULL == newbuf)
+			break;
+		buf = newbuf;
+	}
 
 	/* hmm. fall back to the current dir */
-	if (getcwd(buf, PATH_MAX))
-		return str_dup(buf);
+	if (buf)
+		return buf;
 #endif
 	return str_dup(".");
 }
>From 1c78ebc049131fe8d4a2aeaceef4bc53fee41656 Mon Sep 17 00:00:00 2001
From: Petter Reinholdtsen <pere@hungry.com>
Date: Sat, 13 Jul 2024 18:47:31 +0200
Subject: [PATCH] Drop use of PATH_MAX on non-Windows platforms.

There is no need to hardcode a maximum size limit for home directory path nor
backup file name paths, and dropping the artificial limit get the source building
on GNU Hurd.
---
 schism/util.c | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/schism/util.c b/schism/util.c
index cbf70f56..967528ce 100644
--- a/schism/util.c
+++ b/schism/util.c
@@ -617,10 +617,10 @@ int get_num_lines(const char *text)
 /* 0 = success, !0 = failed (check errno) */
 int make_backup_file(const char *filename, int numbered)
 {
-	char buf[PATH_MAX];
+	int ret = 0;
+	char *buf = malloc(strlen(filename) + 16);
 
-	/* ensure plenty of room to breathe */
-	if (strlen(filename) > PATH_MAX - 16) {
+	if (NULL == buf) {
 		errno = ENAMETOOLONG;
 		return -1;
 	}
@@ -628,16 +628,19 @@ int make_backup_file(const char *filename, int numbered)
 	if (numbered) {
 		/* If some crazy person needs more than 65536 backup files,
 		   they probably have more serious issues to tend to. */
-		int n = 1, ret;
+		int n = 1;
 		do {
 			sprintf(buf, "%s.%d~", filename, n++);
 			ret = rename_file(filename, buf, 0);
 		} while (ret != 0 && errno == EEXIST && n < 65536);
+		free(buf);
 		return ret;
 	} else {
 		strcpy(buf, filename);
 		strcat(buf, "~");
-		return rename_file(filename, buf, 1);
+		ret = rename_file(filename, buf, 1);
+		free(buf);
+		return ret;
 	}
 }
 
@@ -783,10 +786,22 @@ char *get_current_directory(void)
 	if (_wgetcwd(buf, PATH_MAX) && !charset_iconv((uint8_t*)buf, &buf_utf8, CHARSET_WCHAR_T, CHARSET_UTF8))
 		return (char*)buf_utf8;
 #else
-	char buf[PATH_MAX + 1] = {'\0'};
-
-	if (getcwd(buf, PATH_MAX))
-		return str_dup(buf);
+       /* Double the buffer size until getcwd() succeed or we run out
+	  of memory.  Not using get_current_dir_name() and
+	  getcwd(NULL, n) to only use methods defined by POSIX. */
+       size_t n = 1024;
+       char *buf = malloc(n);
+       while (buf && NULL == getcwd(buf, n)) {
+	       n *= 2;
+	       char *newbuf = realloc(buf, n);
+	       if (NULL == newbuf)
+		       break;
+	       buf = newbuf;
+       }
+
+
+       if (buf)
+	       return buf;
 #endif
 	return str_dup(".");
 }
-- 
2.39.2


--- End Message ---
--- Begin Message ---
Source: schism
Source-Version: 2:20240809-1
Done: Dennis Braun <snd@debian.org>

We believe that the bug you reported is fixed in the latest version of
schism, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1076285@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Dennis Braun <snd@debian.org> (supplier of updated schism package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Sat, 17 Aug 2024 14:32:40 +0200
Source: schism
Architecture: source
Version: 2:20240809-1
Distribution: unstable
Urgency: medium
Maintainer: Debian Multimedia Maintainers <debian-multimedia@lists.debian.org>
Changed-By: Dennis Braun <snd@debian.org>
Closes: 1076285
Changes:
 schism (2:20240809-1) unstable; urgency=medium
 .
   * New upstream version 20240809
   * Drop use of PATH_MAX on non Windows platforms (Closes: #1076285)
     Thanks to Petter Reinholdtsen for the patch
Checksums-Sha1:
 5d2ff94a3490ece59e49daf76fc714f810dd88bf 2072 schism_20240809-1.dsc
 d2e03aa28a85144437d01b6931354237404ea924 1088121 schism_20240809.orig.tar.gz
 6bec2dabd83aa95bb3bfb4c8ca74971a4cb94441 6244 schism_20240809-1.debian.tar.xz
 4467ef0c1663942966bee169ab7bbf8798b2b402 7097 schism_20240809-1_source.buildinfo
Checksums-Sha256:
 931272de7a632b583b4c276c8c04e803b450f113af9e922307082107bc9785a8 2072 schism_20240809-1.dsc
 4dafacc4db2516629d377097573a3cad9ee41de44b2f3c956b360779440168e0 1088121 schism_20240809.orig.tar.gz
 8fa2db68452256662b404546d402d610a8557419e2d3ef85fc37f7faa958f85e 6244 schism_20240809-1.debian.tar.xz
 cdb9b1efa9111786416b802bfd5904c14af7ccf893ab93c77058c517b2f61e9e 7097 schism_20240809-1_source.buildinfo
Files:
 7c6bc95051232e71239d94ebca8c0db3 2072 sound optional schism_20240809-1.dsc
 340bf52dcb1f7518de0d8a60badbeee8 1088121 sound optional schism_20240809.orig.tar.gz
 ba236cb9bc7504664d2717739ad1a45e 6244 sound optional schism_20240809-1.debian.tar.xz
 f09a72984021d9e3d9bd1dce8afe411f 7097 sound optional schism_20240809-1_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEPLfDAq+1fmGoxhfdY06lXZArmDYFAmbAmH4PHHNuZEBkZWJp
YW4ub3JnAAoJEGNOpV2QK5g2VR4QAKDvtjNqShiF1dtHf8ZTJXRM2qEgPuUYWDEQ
jVFVi15DEyTTwONKP9UJ+uoK9nujtcAzCmseYJr2quBKbcCUFa0U/i6aweXNKoJx
Lg0OblcSTHrMoIzNpAmBaxDW9gvjIDJaoV1IrGI6+v7V8/zlb4BXQpC3lWltMJa1
OwG+JDbb8e81uqExi0csw0kef98l6AWO5AzxwyrTY428rFIM+V5vUmjibsvbWEJ1
SsHdZxoniKnKpVau6JSZ7RjgSQJn9XK0gVQd6IYWDdogaLWgbkO+ekV8qOL144ua
RmHDWWKq4sE19MyLKg0brHgpskxqP19VCbFsurzu+QT0k0opz/ZcuE6clJEBg1nM
8X7vjMeYlkkDKh/QFAR4cZSIMqyE9drJbIYEZlXPXAafiqaUDA9i2XUAcXLFBaqS
Peu6S6Koq/OtI0UZoPhuX5aDyL8bQEhlIGSZuhytrg9YLzsxErCeGPCSKkrUJXqq
pGZhPwTiRXkvFdL8M5nWeZFDJDiVY/jZVs3Sba8/e89/KDqdXhQbtWdHe8TKYc2T
TrjYMz/WkNuvr2yCYHO4Fygbaw66f/nAYoknUzpc4MgcbI0TMQrDVaZx3iiytpcD
6wGFFRid8E+Cl1LN6E8QI21X3mfIoNbi2M4DAxyE2AhrE/MdUeMcCZpHrLupANsO
hOmZHVSL
=yyV6
-----END PGP SIGNATURE-----

Attachment: pgp1xYEfonia5.pgp
Description: PGP signature


--- End Message ---

Reply to: