Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-1305

zookeeper.c:prepend_string func can dereference null ptr

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.3.3
    • Fix Version/s: 3.4.1, 3.3.6, 3.5.0
    • Component/s: c client
    • Labels:
    • Environment:

      All

    • Release Note:
      return ZBADARGUMENTS when passed NULL zhandle instead of dereferencing null pointer.

      Description

      All the callers of the function prepend_string make a call to prepend_string before checking that zhandle_t *zh is not null. At the top of prepend_string, zh is dereferenced without checking for a null ptr:

      static char* prepend_string(zhandle_t zh, const char client_path) {
      char *ret_str;
      if (zh->chroot == NULL)
      return (char *) client_path;

      I propose fixing this by adding the check here in prepend_string:

      static char* prepend_string(zhandle_t zh, const char client_path) {
      char *ret_str;
      if (zh==NULL || zh->chroot == NULL)
      return (char *) client_path;

        Attachments

        1. ZOOKEEPER-1305.patch
          1 kB
          Daniel Lescohier
        2. ZOOKEEPER-1305.patch
          1 kB
          Daniel Lescohier

          Issue Links

            Activity

              People

              • Assignee:
                dlescohier Daniel Lescohier
                Reporter:
                dlescohier Daniel Lescohier
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 0.5h
                  0.5h
                  Remaining:
                  Remaining Estimate - 0.5h
                  0.5h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified