Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Jul 2011 11:33:53 +0200
From:      Robert Millan <rmh@debian.org>
To:        freebsd-hackers@freebsd.org, Ed Maste <emaste@freebsd.org>
Cc:        debian-hurd@lists.debian.org
Subject:   [PATCH] avoid assuming MAXPATHLEN in config(8)
Message-ID:  <CAOfDtXNreaFYKvyR_C15dk9mOqU30_Z4gHxQPkPH5ntY7rRtzA@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
--bcaec520e99355367704a7776a02
Content-Type: text/plain; charset=UTF-8

config(8) assumes MAXPATHLEN is defined in a few places, but presence
of this macro isn't garanteed (POSIX says that it is only present when
a file length limit exists, which may not be the case).

This patch fixes a usr.sbin/config compile problem on Debian GNU/Hurd
by using dynamic allocation.  Doing so also reduces its memory
footprint and safeguards against possible error conditions when
zero-length pathnames are used.

-- 
Robert Millan

--bcaec520e99355367704a7776a02
Content-Type: text/plain; charset=US-ASCII; name="config_maxpathlen.diff"
Content-Disposition: attachment; filename="config_maxpathlen.diff"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_gptioq3a0

SW5kZXg6IHVzci5zYmluL2NvbmZpZy9ta29wdGlvbnMuYwo9PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSB1c3Iuc2Jp
bi9jb25maWcvbWtvcHRpb25zLmMJKHJldmlzaW9uIDIyMzc5MikKKysrIHVzci5zYmluL2NvbmZp
Zy9ta29wdGlvbnMuYwkod29ya2luZyBjb3B5KQpAQCAtMjkwLDIyICsyOTAsMjEgQEAKIHN0YXRp
YyBjaGFyICoKIHRvb3B0aW9uKGNoYXIgKm5hbWUpCiB7Ci0Jc3RhdGljIGNoYXIgaGJ1ZltNQVhQ
QVRITEVOXTsKLQljaGFyIG5idWZbTUFYUEFUSExFTl07CisJY2hhciAqbmJ1ZjsKIAlzdHJ1Y3Qg
b3B0X2xpc3QgKnBvOwogCiAJLyogImNhbm5v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T09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIHVzci5zYmluL2Nv
bmZpZy9jb25maWcuaAkocmV2aXNpb24gMjIzNzkyKQorKysgdXNyLnNiaW4vY29uZmlnL2NvbmZp
Zy5oCSh3b3JraW5nIGNvcHkpCkBAIC0xOTksNyArMTk5LDcgQEAKIGV4dGVybiBpbnQJbWF4dXNl
cnM7CiAKIGV4dGVybiBjaGFyICpQUkVGSVg7CQkvKiBDb25maWcgZmlsZSBuYW1lIC0gZm9yIGVy
cm9yIG1lc3NhZ2VzICovCi1leHRlcm4gY2hhciBzcmNkaXJbXTsJCS8qIHJvb3Qgb2YgdGhlIGtl
cm5lbCBzb3VyY2UgdHJlZSAqLworZXh0ZXJuIGNoYXIgKnNyY2RpcjsJCS8qIHJvb3Qgb2YgdGhl
IGtlcm5lbCBzb3VyY2UgdHJlZSAqLwogCiAjZGVmaW5lIGVxKGEsYikJKCFzdHJjbXAoYSxiKSkK
ICNkZWZpbmUgbnMocykJc3RyZHVwKHMpCg==
--bcaec520e99355367704a7776a02--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOfDtXNreaFYKvyR_C15dk9mOqU30_Z4gHxQPkPH5ntY7rRtzA>