Skip to contentSkip to conversation

udev_rules_apply_format(): do not process substituted

PATCH In review Sergey Vlasov 2 participants 3 messages Feb 1, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 udev_rules_apply_format(): do not process substituted

Substituted values may contain parts which look like format elements, but they must not be interpreted as such, so skip the substituted value before looking for more format elements.

---
 udev_rules.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
udev_rules.c +1 -0
index 90a83e5..a481712 100644
@@ -562,6 +562,7 @@ found:
 			head[len] = '\0';
 			dbg("truncate to %i chars, subtitution string becomes '%s'", len, head);
 		}
+		head = strchr(string, '\0');
 		strlcat(string, temp, maxsize);
 	}
 }
Signature · 12 lines
1.5.0.rc2.gd894fb


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#1 lore raw
Quoted 3 lines · Sergey Vlasov

Substituted values may contain parts which look like format elements, but they must not be interpreted as such, so skip the substituted value before looking for more format elements.

I've seen people using this and returning format chars for further substitution. We also have a test for it, it break "make test", right?.

Do you have a special reason to preserve format-chars returned by a program?

Kay

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#2 lore raw
In reply to Sergey Vlasov
Quoted 8 lines · Kay Sievers
Quoted 3 lines · Sergey Vlasov

Substituted values may contain parts which look like format elements, but they must not be interpreted as such, so skip the substituted value before looking for more format elements.

I've seen people using this and returning format chars for further substitution. We also have a test for it, it break "make test", right?.

Oops, sorry. (Running these tests is a hassle, because they need root permissions, therefore they cannot be run automatically when building the package; and tests for big majors fail on XFS with 2.6.18 - apparently this FS does not support them.)

Quoted 1 line

Do you have a special reason to preserve format-chars returned by a program?

The main problem is vol_id, which happily passes these chars into ID_FS_LABEL_SAFE, where they then expand to something unexpected (or even crash the event handling process if the label is something like "%1000000m" - one of my patches fixes that bug). Should vol_id (and other *_id programs) escape these characters? But then quoting would become incompatible with shell (which, BTW, is also broken now; spaces in the label break even udev, and '\n' leads to a complete disaster).

Also, this recursive expansion is unexpected in general and does not seem to be documented in udev(7) (the man page says "printf-like", which suggests non-recursive behavior). AFAIK, only m4 has similar recursive expansion (and it is also very hard to use properly). I understand that this feature could be useful, but it needs to be documented in the man page in big letters - otherwise people will continue to write unsafe rules.

In summary, all those expansion and quoting at various places needs to be checked, documented and in most cases fixed to behave properly.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel