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

Proposed by James Hunt
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 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.
Revision history for this message
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
=== modified file 'ChangeLog'
--- ChangeLog 2011-08-26 18:31:43 +0000
+++ ChangeLog 2011-08-30 19:25:14 +0000
@@ -1,3 +1,17 @@
12011-08-30 James Hunt <james.hunt@ubuntu.com>
2
3 * nih-dbus-tool/tests/test_com.netsplit.Nih.Test_object.c
4 (test_unix_fd_to_str): Sanity check value before invoking strchr in
5 case it returns address of null (which would give a misleading test
6 pass).
7 * nih-dbus-tool/tests/test_com.netsplit.Nih.Test_proxy.c
8 (test_unix_fd_to_str, test_unix_fd_to_str_sync): Sanity check value
9 before invoking strchr in case it returns address of null (which would
10 give a misleading test pass).
11 * nih/config.c (): nih_config_block_end: Add check to ensure strchr()
12 doesn't return address of null since this would result in a misleading
13 return value of TRUE.
14
12011-08-26 James Hunt <james.hunt@ubuntu.com>152011-08-26 James Hunt <james.hunt@ubuntu.com>
216
3 * nih/io.c (nih_io_select_fds): Ensure number of fds being managed17 * nih/io.c (nih_io_select_fds): Ensure number of fds being managed
418
=== modified file 'nih-dbus-tool/tests/test_com.netsplit.Nih.Test_object.c'
--- nih-dbus-tool/tests/test_com.netsplit.Nih.Test_object.c 2010-12-23 21:48:04 +0000
+++ nih-dbus-tool/tests/test_com.netsplit.Nih.Test_object.c 2011-08-30 19:25:14 +0000
@@ -12524,6 +12524,7 @@
12524 dbus_message_iter_init (reply, &iter);12524 dbus_message_iter_init (reply, &iter);
1252512525
12526 dbus_message_iter_get_basic (&iter, &str_value);12526 dbus_message_iter_get_basic (&iter, &str_value);
12527 TEST_NE (str_value[0], '\0');
12527 TEST_TRUE (strchr ("0123456789", str_value[0]));12528 TEST_TRUE (strchr ("0123456789", str_value[0]));
1252812529
12529 dbus_message_unref (reply);12530 dbus_message_unref (reply);
1253012531
=== modified file 'nih-dbus-tool/tests/test_com.netsplit.Nih.Test_proxy.c'
--- nih-dbus-tool/tests/test_com.netsplit.Nih.Test_proxy.c 2010-12-23 21:48:04 +0000
+++ nih-dbus-tool/tests/test_com.netsplit.Nih.Test_proxy.c 2011-08-30 19:25:14 +0000
@@ -27359,6 +27359,7 @@
27359 TEST_TRUE (unix_fd_to_str_replied);27359 TEST_TRUE (unix_fd_to_str_replied);
2736027360
27361 TEST_EQ_P (last_data, parent);27361 TEST_EQ_P (last_data, parent);
27362 TEST_NE (last_str_value[0], '\0');
27362 TEST_TRUE (strchr ("0123456789", last_str_value[0]));27363 TEST_TRUE (strchr ("0123456789", last_str_value[0]));
27363 TEST_ALLOC_PARENT (last_str_value, parent);27364 TEST_ALLOC_PARENT (last_str_value, parent);
2736427365
@@ -27673,6 +27674,7 @@
2767327674
27674 TEST_EQ (ret, 0);27675 TEST_EQ (ret, 0);
2767527676
27677 TEST_NE (str_value[0], '\0');
27676 TEST_TRUE (strchr ("0123456789", str_value[0]));27678 TEST_TRUE (strchr ("0123456789", str_value[0]));
27677 TEST_ALLOC_PARENT (str_value, parent);27679 TEST_ALLOC_PARENT (str_value, parent);
2767827680
2767927681
=== modified file 'nih/config.c'
--- nih/config.c 2011-08-26 18:28:37 +0000
+++ nih/config.c 2011-08-30 19:25:14 +0000
@@ -950,7 +950,7 @@
950 return FALSE;950 return FALSE;
951951
952 /* Must be whitespace after */952 /* Must be whitespace after */
953 if (! strchr (NIH_CONFIG_WS, file[p + 3]))953 if (file[p + 3] && ! strchr (NIH_CONFIG_WS, file[p + 3]))
954 return FALSE;954 return FALSE;
955955
956 /* Find the second word */956 /* Find the second word */

Subscribers

People subscribed via source and target branches