summaryrefslogtreecommitdiff
path: root/udev.h
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2004-02-28 01:59:02 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:34:28 -0700
commitc58e36c092ad5acc84d35e455ecc74096b25ae66 (patch)
tree6030871e62499303759ecf4660fc26d9b3683004 /udev.h
parent7eb136adb8fe265050b2a3e44b216e747163743f (diff)
[PATCH] udev - safer sprintf() use
Here is for now my last patch to the string handling for a rather theorethical case, where the node is very very very long. :) We have accordant to strfieldcat(to, from) now a strintcat(to, i) macro, which appends the ascii representation of a integer to a string in a safe way.
Diffstat (limited to 'udev.h')
-rw-r--r--udev.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/udev.h b/udev.h
index 3b676acf40..5737c84c9d 100644
--- a/udev.h
+++ b/udev.h
@@ -85,6 +85,18 @@ do { \
strncat(to, from, maxsize - strlen(to)-1); \
} while (0)
+#define strintcat(to, i) \
+do { \
+ to[sizeof(to)-1] = '\0'; \
+ snprintf((to) + strlen(to), sizeof(to) - strlen(to)-1, "%u", i); \
+} while (0)
+
+#define strnintcat(to, i, maxsize) \
+do { \
+ to[maxsize-1] = '\0'; \
+ snprintf((to) + strlen(to), maxsize - strlen(to)-1, "%u", i); \
+} while (0)
+
static inline char *get_action(void)
{
char *action;