]> granicus.if.org Git - strace/commitdiff
Fix struct xlat initialization bugs
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 3 Mar 2011 01:02:41 +0000 (01:02 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 3 Mar 2011 01:02:41 +0000 (01:02 +0000)
* file.c (inotify_modes): Terminate with NULL entry.
* net.c (sock_type_flags): Make this array static.
(socketlayers): Add a comment that this array should remain not
NULL-terminated.

file.c
net.c

diff --git a/file.c b/file.c
index dc17854f21a55da92d51512da5a8d1ca68dbff07..15db40f82f0ca264f8f8d22f085f085de10bf292 100644 (file)
--- a/file.c
+++ b/file.c
@@ -2918,26 +2918,27 @@ sys_fadvise64_64(struct tcb *tcp)
 
 #ifdef LINUX
 static const struct xlat inotify_modes[] = {
-       { 0x00000001, "IN_ACCESS" },
-       { 0x00000002, "IN_MODIFY" },
-       { 0x00000004, "IN_ATTRIB" },
-       { 0x00000008, "IN_CLOSE_WRITE" },
-       { 0x00000010, "IN_CLOSE_NOWRITE" },
-       { 0x00000020, "IN_OPEN" },
-       { 0x00000040, "IN_MOVED_FROM" },
-       { 0x00000080, "IN_MOVED_TO" },
-       { 0x00000100, "IN_CREATE" },
-       { 0x00000200, "IN_DELETE" },
-       { 0x00000400, "IN_DELETE_SELF" },
-       { 0x00000800, "IN_MOVE_SELF" },
-       { 0x00002000, "IN_UNMOUNT" },
-       { 0x00004000, "IN_Q_OVERFLOW" },
-       { 0x00008000, "IN_IGNORED" },
-       { 0x01000000, "IN_ONLYDIR" },
-       { 0x02000000, "IN_DONT_FOLLOW" },
-       { 0x20000000, "IN_MASK_ADD" },
-       { 0x40000000, "IN_ISDIR" },
-       { 0x80000000, "IN_ONESHOT" }
+       { 0x00000001,   "IN_ACCESS"     },
+       { 0x00000002,   "IN_MODIFY"     },
+       { 0x00000004,   "IN_ATTRIB"     },
+       { 0x00000008,   "IN_CLOSE_WRITE"},
+       { 0x00000010,   "IN_CLOSE_NOWRITE"},
+       { 0x00000020,   "IN_OPEN"       },
+       { 0x00000040,   "IN_MOVED_FROM" },
+       { 0x00000080,   "IN_MOVED_TO"   },
+       { 0x00000100,   "IN_CREATE"     },
+       { 0x00000200,   "IN_DELETE"     },
+       { 0x00000400,   "IN_DELETE_SELF"},
+       { 0x00000800,   "IN_MOVE_SELF"  },
+       { 0x00002000,   "IN_UNMOUNT"    },
+       { 0x00004000,   "IN_Q_OVERFLOW" },
+       { 0x00008000,   "IN_IGNORED"    },
+       { 0x01000000,   "IN_ONLYDIR"    },
+       { 0x02000000,   "IN_DONT_FOLLOW"},
+       { 0x20000000,   "IN_MASK_ADD"   },
+       { 0x40000000,   "IN_ISDIR"      },
+       { 0x80000000,   "IN_ONESHOT"    },
+       { 0,            NULL            }
 };
 
 int
diff --git a/net.c b/net.c
index 26cfeb037dea1196b4a32149cc968d1d6208af5f..cafa739625c0726e194151ec2851aa4bf1f3de46 100644 (file)
--- a/net.c
+++ b/net.c
@@ -337,7 +337,7 @@ static const struct xlat socktypes[] = {
 #endif
        { 0,            NULL            },
 };
-const struct xlat sock_type_flags[] = {
+static const struct xlat sock_type_flags[] = {
 #ifdef SOCK_CLOEXEC
        { SOCK_CLOEXEC, "SOCK_CLOEXEC"  },
 #endif
@@ -447,6 +447,7 @@ static const struct xlat socketlayers[] = {
        { SOL_CAIF,     "SOL_CAIF"      },
 #endif
        { SOL_SOCKET,   "SOL_SOCKET"    },      /* Never used! */
+       /* The SOL_* array should remain not NULL-terminated. */
 };
 /*** WARNING: DANGER WILL ROBINSON: NOTE "socketlayers" array above
      falls into "protocols" array below!!!!   This is intended!!! ***/