Skip to content

Commit

Permalink
Fix vold vulnerability in FrameworkListener am: 470484d am: e9e046d am:
Browse files Browse the repository at this point in the history
109024f am: b906ad8 am: 2fadbb9 am: e04054d am: 9745b11

am: 2f78b2c

Change-Id: I9e1bd65c9ae556b8115bef24449b502417718807
  • Loading branch information
cobrien7 authored and android-build-merger committed Aug 19, 2016
2 parents c0e52f1 + 2f78b2c commit 2b5e6d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/sysutils/FrameworkListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class FrameworkListener : public SocketListener {
int mCommandCount;
bool mWithSeq;
FrameworkCommandCollection *mCommands;
bool mSkipToNextNullByte;

public:
FrameworkListener(const char *socketName);
Expand Down
17 changes: 14 additions & 3 deletions libsysutils/src/FrameworkListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void FrameworkListener::init(const char *socketName UNUSED, bool withSeq) {
errorRate = 0;
mCommandCount = 0;
mWithSeq = withSeq;
mSkipToNextNullByte = false;
}

bool FrameworkListener::onDataAvailable(SocketClient *c) {
Expand All @@ -59,22 +60,32 @@ bool FrameworkListener::onDataAvailable(SocketClient *c) {
if (len < 0) {
SLOGE("read() failed (%s)", strerror(errno));
return false;
} else if (!len)
} else if (!len) {
return false;
if(buffer[len-1] != '\0')
} else if (buffer[len-1] != '\0') {
SLOGW("String is not zero-terminated");
android_errorWriteLog(0x534e4554, "29831647");
c->sendMsg(500, "Command too large for buffer", false);
mSkipToNextNullByte = true;
return false;
}

int offset = 0;
int i;

for (i = 0; i < len; i++) {
if (buffer[i] == '\0') {
/* IMPORTANT: dispatchCommand() expects a zero-terminated string */
dispatchCommand(c, buffer + offset);
if (mSkipToNextNullByte) {
mSkipToNextNullByte = false;
} else {
dispatchCommand(c, buffer + offset);
}
offset = i + 1;
}
}

mSkipToNextNullByte = false;
return true;
}

Expand Down

0 comments on commit 2b5e6d8

Please sign in to comment.