Skip to contentSkip to conversation

Make new_utsname fields use the proper length constant

PATCH In review Dan Smith 3 participants 3 messages Apr 17, 2009 1 message not in the archive

lore
Share & tools
lore

Dan Smith

author
#0 lore raw

PATCH 1/1 Make new_utsname fields use the proper length constant

The members of the new_utsname structure are defined with magic numbers that *should* correspond to the constant __NEW_UTS_LEN+1. Everywhere else, code assumes this and uses the constant, so this patch makes the structure match.

Originally suggested by Serge here:

https://lists.linux-foundation.org/pipermail/containers/2009-March/016258.html

Cc containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
---
 include/linux/utsname.h |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
include/linux/utsname.h +6 -6
index 1123267..3656b30 100644
@@ -22,12 +22,12 @@ struct old_utsname {
 };
 
 struct new_utsname {
-	char sysname[65];
-	char nodename[65];
-	char release[65];
-	char version[65];
-	char machine[65];
-	char domainname[65];
+	char sysname[__NEW_UTS_LEN + 1];
+	char nodename[__NEW_UTS_LEN + 1];
+	char release[__NEW_UTS_LEN + 1];
+	char version[__NEW_UTS_LEN + 1];
+	char machine[__NEW_UTS_LEN + 1];
+	char domainname[__NEW_UTS_LEN + 1];
 };
 
 #ifdef __KERNEL__
Signature · 1 line
1.5.6.3

A message that is not in the archive (sent off-list or not yet received): 1239988696-18140-1-git-send-email-danms-r/[email protected]

#2 lore raw
Quoted 5 lines · Dan Smith

The members of the new_utsname structure are defined with magic numbers that *should* correspond to the constant __NEW_UTS_LEN+1. Everywhere else, code assumes this and uses the constant, so this patch makes the structure match.

Quoted 8 lines

Originally suggested by Serge here:

https://lists.linux-foundation.org/pipermail/containers/2009-March/016258.html

Cc containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org

I realize it's weird putting __NEW_UTS_LEN+1 in the length for struct old_utsname :), but you didn't make up the names, so I would argue just do it for both old_utsname and oldold_utsname too...

But of course even if you don't want to,

thanks, Dan.

-serge

Quoted 29 lines
---
 include/linux/utsname.h |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
include/linux/utsname.h +6 -6
index 1123267..3656b30 100644
@@ -22,12 +22,12 @@ struct old_utsname {
 };
 
 struct new_utsname {
-	char sysname[65];
-	char nodename[65];
-	char release[65];
-	char version[65];
-	char machine[65];
-	char domainname[65];
+	char sysname[__NEW_UTS_LEN + 1];
+	char nodename[__NEW_UTS_LEN + 1];
+	char release[__NEW_UTS_LEN + 1];
+	char version[__NEW_UTS_LEN + 1];
+	char machine[__NEW_UTS_LEN + 1];
+	char domainname[__NEW_UTS_LEN + 1];
 };
 
 #ifdef __KERNEL__
Signature · 1 line
1.5.6.3
Acked-by on v1 1/1
#3 lore raw
In reply to Dan Smith
Quoted 5 lines · Dan Smith

The members of the new_utsname structure are defined with magic numbers that *should* correspond to the constant __NEW_UTS_LEN+1. Everywhere else, code assumes this and uses the constant, so this patch makes the structure match.

Quoted 8 lines

Originally suggested by Serge here:

https://lists.linux-foundation.org/pipermail/containers/2009-March/016258.html

I realize it's weird putting __NEW_UTS_LEN+1 in the length for struct old_utsname :), but you didn't make up the names, so I would argue just do it for both old_utsname and oldold_utsname too...

But of course even if you don't want to,

thanks, Dan.

-serge

Quoted 29 lines
---
 include/linux/utsname.h |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
include/linux/utsname.h +6 -6
index 1123267..3656b30 100644
@@ -22,12 +22,12 @@ struct old_utsname {
 };
 
 struct new_utsname {
-	char sysname[65];
-	char nodename[65];
-	char release[65];
-	char version[65];
-	char machine[65];
-	char domainname[65];
+	char sysname[__NEW_UTS_LEN + 1];
+	char nodename[__NEW_UTS_LEN + 1];
+	char release[__NEW_UTS_LEN + 1];
+	char version[__NEW_UTS_LEN + 1];
+	char machine[__NEW_UTS_LEN + 1];
+	char domainname[__NEW_UTS_LEN + 1];
 };
 
 #ifdef __KERNEL__
Signature · 1 line
1.5.6.3