ZooKeeper
  1. ZooKeeper
  2. ZOOKEEPER-1305

zookeeper.c:prepend_string func can dereference null ptr

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major 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;

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

        Issue Links

          Activity

          Daniel Lescohier created issue -
          Daniel Lescohier made changes -
          Field Original Value New Value
          Status Open [ 1 ] Patch Available [ 10002 ]
          Release Note return ZBADARGUMENTS when passed NULL zhandle instead of dereferencing null pointer.
          Labels patch
          Daniel Lescohier made changes -
          Attachment ZOOKEEPER-1305.patch [ 12504662 ]
          Daniel Lescohier made changes -
          Attachment ZOOKEEPER-1305.patch [ 12504766 ]
          Patrick Hunt made changes -
          Assignee Daniel Lescohier [ dlescohier ]
          Patrick Hunt made changes -
          Fix Version/s 3.5.0 [ 12316644 ]
          Fix Version/s 3.4.1 [ 12318650 ]
          Mahadev konar made changes -
          Status Patch Available [ 10002 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Mahadev konar made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Henry Robinson made changes -
          Link This issue is duplicated by ZOOKEEPER-1461 [ ZOOKEEPER-1461 ]
          Michi Mutsuzaki made changes -
          Fix Version/s 3.3.6 [ 12320172 ]

            People

            • Assignee:
              Daniel Lescohier
              Reporter:
              Daniel Lescohier
            • Votes:
              0 Vote for this issue
              Watchers:
              1 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

                  Development