From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Buesch Date: Sat, 05 Feb 2005 17:18:49 +0000 Subject: [PATCH, UDEV] change no_trailing_slash() to remove all trailing slashes Message-Id: <200502051818.54277.mbuesch@freenet.de> MIME-Version: 1 Content-Type: multipart/mixed; boundary="nextPart11305417.Urj0dr8DN2" List-Id: To: linux-hotplug@vger.kernel.org --nextPart11305417.Urj0dr8DN2 Content-Type: multipart/mixed; boundary="Boundary-01=_5/PBCJw5arDlpem" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_5/PBCJw5arDlpem Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, This changes no_trailing_slash() to remove all trailing slashes and not just the last one. This protects against crazy users which do: export SYSFS_PATH=3D"/sys//" or something similiar. =2D-=20 Regards Michael Buesch [ http://www.tuxsoft.de.vu ] --Boundary-01=_5/PBCJw5arDlpem Content-Type: text/x-diff; charset="us-ascii"; name="udev_no_trailing_slash.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="udev_no_trailing_slash.diff" =3D=3D=3D=3D=3D udev_utils.c 1.25 vs edited =3D=3D=3D=3D=3D =2D-- 1.25/udev_utils.c 2004-12-20 22:10:57 +01:00 +++ edited/udev_utils.c 2005-02-05 18:13:46 +01:00 @@ -200,11 +200,11 @@ =20 void no_trailing_slash(char *path) { =2D int len; + size_t len; =20 len =3D strlen(path); =2D if (len > 0 && path[len-1] =3D=3D '/') =2D path[len-1] =3D '\0'; + while (len > 0 && path[len-1] =3D=3D '/') + path[--len] =3D '\0'; } =20 struct files { --Boundary-01=_5/PBCJw5arDlpem-- --nextPart11305417.Urj0dr8DN2 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQBCBP/+FGK1OIvVOP4RAkNTAKDNuJeghBWFb+3mCnwi29LnNYwBiQCfV0Co 5q/YnBIuTu+3XUibxXiEnFA= =LNkw -----END PGP SIGNATURE----- --nextPart11305417.Urj0dr8DN2-- ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel