Merge lp:~jamesodhunt/libnih/strchr-fixes into lp:libnih

Proposed by James Hunt on 2011-08-30
Status: Merged
Merged at revision: 1054
Proposed branch: lp:~jamesodhunt/libnih/strchr-fixes
Merge into: lp:libnih
Diff against target: 66 lines (+18/-1)
4 files modified
ChangeLog (+14/-0)
nih-dbus-tool/tests/test_com.netsplit.Nih.Test_object.c (+1/-0)
nih-dbus-tool/tests/test_com.netsplit.Nih.Test_proxy.c (+2/-0)
nih/config.c (+1/-1)
To merge this branch: bzr merge lp:~jamesodhunt/libnih/strchr-fixes
Reviewer Review Type Date Requested Status
Scott James Remnant 2011-08-30 Pending
Review via email: mp+73431@code.launchpad.net

Description of the change

      * nih-dbus-tool/tests/test_com.netsplit.Nih.Test_object.c
        (test_unix_fd_to_str): Sanity check value before invoking strchr in
        case it returns address of null (which would give a misleading test
        pass).
      * nih-dbus-tool/tests/test_com.netsplit.Nih.Test_proxy.c
        (test_unix_fd_to_str, test_unix_fd_to_str_sync): Sanity check value
        before invoking strchr in case it returns address of null (which would
        give a misleading test pass).
      * nih/config.c (): nih_config_block_end: Add check to ensure strchr()
        doesn't return address of null since this would result in a misleading
        return value of TRUE.

To post a comment you must log in.
James Hunt (jamesodhunt) wrote :

Hi Scott,

Regarding the comments on: https://code.launchpad.net/~jamesodhunt/libnih/fix-for-bug-834813/+merge/73383 wrt existing strchr usage, these were the only instances of strchr() I could find that could return bogus values.

Cheers,

James.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2011-08-26 18:31:43 +0000
3+++ ChangeLog 2011-08-30 19:25:14 +0000
4@@ -1,3 +1,17 @@
5+2011-08-30 James Hunt <james.hunt@ubuntu.com>
6+
7+ * nih-dbus-tool/tests/test_com.netsplit.Nih.Test_object.c
8+ (test_unix_fd_to_str): Sanity check value before invoking strchr in
9+ case it returns address of null (which would give a misleading test
10+ pass).
11+ * nih-dbus-tool/tests/test_com.netsplit.Nih.Test_proxy.c
12+ (test_unix_fd_to_str, test_unix_fd_to_str_sync): Sanity check value
13+ before invoking strchr in case it returns address of null (which would
14+ give a misleading test pass).
15+ * nih/config.c (): nih_config_block_end: Add check to ensure strchr()
16+ doesn't return address of null since this would result in a misleading
17+ return value of TRUE.
18+
19 2011-08-26 James Hunt <james.hunt@ubuntu.com>
20
21 * nih/io.c (nih_io_select_fds): Ensure number of fds being managed
22
23=== modified file 'nih-dbus-tool/tests/test_com.netsplit.Nih.Test_object.c'
24--- nih-dbus-tool/tests/test_com.netsplit.Nih.Test_object.c 2010-12-23 21:48:04 +0000
25+++ nih-dbus-tool/tests/test_com.netsplit.Nih.Test_object.c 2011-08-30 19:25:14 +0000
26@@ -12524,6 +12524,7 @@
27 dbus_message_iter_init (reply, &iter);
28
29 dbus_message_iter_get_basic (&iter, &str_value);
30+ TEST_NE (str_value[0], '\0');
31 TEST_TRUE (strchr ("0123456789", str_value[0]));
32
33 dbus_message_unref (reply);
34
35=== modified file 'nih-dbus-tool/tests/test_com.netsplit.Nih.Test_proxy.c'
36--- nih-dbus-tool/tests/test_com.netsplit.Nih.Test_proxy.c 2010-12-23 21:48:04 +0000
37+++ nih-dbus-tool/tests/test_com.netsplit.Nih.Test_proxy.c 2011-08-30 19:25:14 +0000
38@@ -27359,6 +27359,7 @@
39 TEST_TRUE (unix_fd_to_str_replied);
40
41 TEST_EQ_P (last_data, parent);
42+ TEST_NE (last_str_value[0], '\0');
43 TEST_TRUE (strchr ("0123456789", last_str_value[0]));
44 TEST_ALLOC_PARENT (last_str_value, parent);
45
46@@ -27673,6 +27674,7 @@
47
48 TEST_EQ (ret, 0);
49
50+ TEST_NE (str_value[0], '\0');
51 TEST_TRUE (strchr ("0123456789", str_value[0]));
52 TEST_ALLOC_PARENT (str_value, parent);
53
54
55=== modified file 'nih/config.c'
56--- nih/config.c 2011-08-26 18:28:37 +0000
57+++ nih/config.c 2011-08-30 19:25:14 +0000
58@@ -950,7 +950,7 @@
59 return FALSE;
60
61 /* Must be whitespace after */
62- if (! strchr (NIH_CONFIG_WS, file[p + 3]))
63+ if (file[p + 3] && ! strchr (NIH_CONFIG_WS, file[p + 3]))
64 return FALSE;
65
66 /* Find the second word */

Subscribers

People subscribed via source and target branches