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

zookeeper.c:prepend_string func can dereference null ptr

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.3.3
    • 3.4.1, 3.3.6, 3.5.0
    • c client
    • All

    • 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

              dlescohier Daniel Lescohier
              dlescohier Daniel Lescohier
              Votes:
              0 Vote for this issue
              Watchers:
              2 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