зеркало из https://github.com/mozilla/gecko-dev.git
Bug 539856: Avoid use-after-free of |mId| when constructing replies to destructor messages by saving |mId| on the stack. no r=, minor
This commit is contained in:
Родитель
6e33770c22
Коммит
8d8174a707
|
@ -3513,6 +3513,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||||
failif = StmtIf(ExprNot(readok))
|
failif = StmtIf(ExprNot(readok))
|
||||||
failif.addifstmt(StmtReturn(_Result.PayloadError))
|
failif.addifstmt(StmtReturn(_Result.PayloadError))
|
||||||
|
|
||||||
|
idvar = ExprVar('__id')
|
||||||
case.addstmts(
|
case.addstmts(
|
||||||
stmts
|
stmts
|
||||||
+ [ failif, Whitespace.NL ]
|
+ [ failif, Whitespace.NL ]
|
||||||
|
@ -3520,8 +3521,11 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||||
for r in md.returns ]
|
for r in md.returns ]
|
||||||
+ self.invokeRecvHandler(md, implicit=0)
|
+ self.invokeRecvHandler(md, implicit=0)
|
||||||
+ [ Whitespace.NL ]
|
+ [ Whitespace.NL ]
|
||||||
|
+ [ StmtDecl(Decl(_actorIdType(), idvar.name),
|
||||||
|
self.protocol.routingId()) ]
|
||||||
+ self.dtorEpilogue(md, md.actorDecl().var())
|
+ self.dtorEpilogue(md, md.actorDecl().var())
|
||||||
+ self.makeReply(md, errfnRecv)
|
+ [ Whitespace.NL ]
|
||||||
|
+ self.makeReply(md, errfnRecv, routingId=idvar)
|
||||||
+ [ Whitespace.NL,
|
+ [ Whitespace.NL,
|
||||||
StmtReturn(_Result.Processed) ])
|
StmtReturn(_Result.Processed) ])
|
||||||
|
|
||||||
|
@ -3572,16 +3576,17 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||||
msgCtorArgs.append(arg)
|
msgCtorArgs.append(arg)
|
||||||
stmts.extend(sstmts)
|
stmts.extend(sstmts)
|
||||||
|
|
||||||
|
routingId = self.protocol.routingId(fromActor)
|
||||||
stmts.extend([
|
stmts.extend([
|
||||||
StmtExpr(ExprAssn(
|
StmtExpr(ExprAssn(
|
||||||
msgvar,
|
msgvar,
|
||||||
ExprNew(Type(md.pqMsgClass()), args=msgCtorArgs))) ]
|
ExprNew(Type(md.pqMsgClass()), args=msgCtorArgs))) ]
|
||||||
+ self.setMessageFlags(md, msgvar, reply=0, actor=fromActor))
|
+ self.setMessageFlags(md, msgvar, reply=0, routingId=routingId))
|
||||||
|
|
||||||
return msgvar, stmts
|
return msgvar, stmts
|
||||||
|
|
||||||
|
|
||||||
def makeReply(self, md, errfn):
|
def makeReply(self, md, errfn, routingId=None):
|
||||||
# TODO special cases for async ctor/dtor replies
|
# TODO special cases for async ctor/dtor replies
|
||||||
if md.decl.type.isAsync():
|
if md.decl.type.isAsync():
|
||||||
return [ ]
|
return [ ]
|
||||||
|
@ -3598,16 +3603,19 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||||
StmtExpr(ExprAssn(
|
StmtExpr(ExprAssn(
|
||||||
replyvar,
|
replyvar,
|
||||||
ExprNew(Type(md.pqReplyClass()), args=replyCtorArgs))) ]
|
ExprNew(Type(md.pqReplyClass()), args=replyCtorArgs))) ]
|
||||||
+ self.setMessageFlags(md, replyvar, reply=1)
|
+ self.setMessageFlags(md, replyvar, reply=1, routingId=routingId)
|
||||||
+[ self.logMessage(md, md.replyCast(replyvar), 'Sending reply ') ])
|
+[ self.logMessage(md, md.replyCast(replyvar), 'Sending reply ') ])
|
||||||
|
|
||||||
return stmts
|
return stmts
|
||||||
|
|
||||||
|
|
||||||
def setMessageFlags(self, md, var, reply, actor=None):
|
def setMessageFlags(self, md, var, reply, routingId=None):
|
||||||
|
if routingId is None:
|
||||||
|
routingId = self.protocol.routingId()
|
||||||
|
|
||||||
stmts = [ StmtExpr(ExprCall(
|
stmts = [ StmtExpr(ExprCall(
|
||||||
ExprSelect(var, '->', 'set_routing_id'),
|
ExprSelect(var, '->', 'set_routing_id'),
|
||||||
args=[ self.protocol.routingId(actor) ])) ]
|
args=[ routingId ])) ]
|
||||||
|
|
||||||
if md.decl.type.isSync():
|
if md.decl.type.isSync():
|
||||||
stmts.append(StmtExpr(ExprCall(
|
stmts.append(StmtExpr(ExprCall(
|
||||||
|
|
Загрузка…
Ссылка в новой задаче