Revert "Prevent null pointer deref in DirectVolume"

This reverts commit a9f423dd7e.
This commit is contained in:
Kenny Root 2010-03-24 20:18:00 -07:00
parent a9f423dd7e
commit da62e7c002
2 changed files with 12 additions and 48 deletions

View file

@ -124,11 +124,8 @@ int DirectVolume::handleBlockEvent(NetlinkEvent *evt) {
} }
void DirectVolume::handleDiskAdded(const char *devpath, NetlinkEvent *evt) { void DirectVolume::handleDiskAdded(const char *devpath, NetlinkEvent *evt) {
int major, minor; mDiskMajor = atoi(evt->findParam("MAJOR"));
if (!getMajorMinorNum(evt, &major, &minor)) { mDiskMinor = atoi(evt->findParam("MINOR"));
LOGE("Could not determine major:minor in handleDiskAdded");
return;
}
const char *tmp = evt->findParam("NPARTS"); const char *tmp = evt->findParam("NPARTS");
if (tmp) { if (tmp) {
@ -167,11 +164,8 @@ void DirectVolume::handleDiskAdded(const char *devpath, NetlinkEvent *evt) {
} }
void DirectVolume::handlePartitionAdded(const char *devpath, NetlinkEvent *evt) { void DirectVolume::handlePartitionAdded(const char *devpath, NetlinkEvent *evt) {
int major, minor; int major = atoi(evt->findParam("MAJOR"));
if (!getMajorMinorNum(evt, &major, &minor)) { int minor = atoi(evt->findParam("MINOR"));
LOGE("Could not determine major:minor in handlePartitionAdded");
return;
}
int part_num; int part_num;
@ -213,11 +207,8 @@ void DirectVolume::handlePartitionAdded(const char *devpath, NetlinkEvent *evt)
} }
void DirectVolume::handleDiskChanged(const char *devpath, NetlinkEvent *evt) { void DirectVolume::handleDiskChanged(const char *devpath, NetlinkEvent *evt) {
int major, minor; int major = atoi(evt->findParam("MAJOR"));
if (!getMajorMinorNum(evt, &major, &minor)) { int minor = atoi(evt->findParam("MINOR"));
LOGE("Could not determine major:minor in handleDiskChanged");
return;
}
if ((major != mDiskMajor) || (minor != mDiskMinor)) { if ((major != mDiskMajor) || (minor != mDiskMinor)) {
return; return;
@ -249,22 +240,14 @@ void DirectVolume::handleDiskChanged(const char *devpath, NetlinkEvent *evt) {
} }
void DirectVolume::handlePartitionChanged(const char *devpath, NetlinkEvent *evt) { void DirectVolume::handlePartitionChanged(const char *devpath, NetlinkEvent *evt) {
int major, minor; int major = atoi(evt->findParam("MAJOR"));
if (!getMajorMinorNum(evt, &major, &minor)) { int minor = atoi(evt->findParam("MINOR"));
LOGE("Could not determine major:minor in handlePartitionChanged");
return;
}
LOGD("Volume %s %s partition %d:%d changed\n", getLabel(), getMountpoint(), major, minor); LOGD("Volume %s %s partition %d:%d changed\n", getLabel(), getMountpoint(), major, minor);
} }
void DirectVolume::handleDiskRemoved(const char *devpath, NetlinkEvent *evt) { void DirectVolume::handleDiskRemoved(const char *devpath, NetlinkEvent *evt) {
int major, minor; int major = atoi(evt->findParam("MAJOR"));
if (!getMajorMinorNum(evt, &major, &minor)) { int minor = atoi(evt->findParam("MINOR"));
LOGE("Could not determine major:minor in handleDiskRemoved");
return;
}
char msg[255]; char msg[255];
LOGD("Volume %s %s disk %d:%d removed\n", getLabel(), getMountpoint(), major, minor); LOGD("Volume %s %s disk %d:%d removed\n", getLabel(), getMountpoint(), major, minor);
@ -276,12 +259,8 @@ void DirectVolume::handleDiskRemoved(const char *devpath, NetlinkEvent *evt) {
} }
void DirectVolume::handlePartitionRemoved(const char *devpath, NetlinkEvent *evt) { void DirectVolume::handlePartitionRemoved(const char *devpath, NetlinkEvent *evt) {
int major, minor; int major = atoi(evt->findParam("MAJOR"));
if (!getMajorMinorNum(evt, &major, &minor)) { int minor = atoi(evt->findParam("MINOR"));
LOGE("Could not determine major:minor in handlePartitionRemoved");
return;
}
char msg[255]; char msg[255];
LOGD("Volume %s %s partition %d:%d removed\n", getLabel(), getMountpoint(), major, minor); LOGD("Volume %s %s partition %d:%d removed\n", getLabel(), getMountpoint(), major, minor);

View file

@ -18,7 +18,6 @@
#define _DEVICEVOLUME_H #define _DEVICEVOLUME_H
#include <utils/List.h> #include <utils/List.h>
#include <sysutils/NetlinkEvent.h>
#include "Volume.h" #include "Volume.h"
@ -26,20 +25,6 @@
typedef android::List<char *> PathCollection; typedef android::List<char *> PathCollection;
inline bool getMajorMinorNum(NetlinkEvent *evt, int *major, int *minor) {
const char *major_str = evt->findParam("MAJOR");
const char *minor_str = evt->findParam("MINOR");
if (major_str == NULL || minor_str == NULL) {
return false;
}
*major = atoi(major_str);
*minor = atoi(minor_str);
return true;
}
class DirectVolume : public Volume { class DirectVolume : public Volume {
public: public:
static const int MAX_PARTITIONS = 4; static const int MAX_PARTITIONS = 4;