~jconti/ubuntu/oneiric/webkit/fix_doc_path

« back to all changes in this revision

Viewing changes to WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mike Hommey
  • Date: 2008-09-27 08:57:48 UTC
  • mfrom: (3.1.6 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080927085748-yhzld00w0rekp961
Tags: 1.0.1-4
WebCore/dom/Document.*, WebCore/loader/DocLoader.*: Avoid DoS via
crafted CSS import statements. Fixes: CVE-2008-3632. Closes: #499771.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2006 Apple Computer, Inc.
 
2
 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3
3
 *
4
4
 * This library is free software; you can redistribute it and/or
5
5
 * modify it under the terms of the GNU Library General Public
13
13
 *
14
14
 * You should have received a copy of the GNU Library General Public License
15
15
 * along with this library; see the file COPYING.LIB.  If not, write to
16
 
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 
 * Boston, MA 02111-1307, USA.
 
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
 * Boston, MA 02110-1301, USA.
18
18
 */
19
19
 
20
20
#include "config.h"
26
26
#include "HTMLOptionsCollection.h"
27
27
#include "HTMLSelectElement.h"
28
28
#include "JSHTMLOptionElement.h"
 
29
#include "JSHTMLSelectElement.h"
29
30
#include "JSHTMLSelectElementCustom.h"
30
31
 
31
 
#include <kjs/operations.h>
 
32
#include <wtf/MathExtras.h>
32
33
 
33
34
using namespace KJS;
34
35
 
45
46
    HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
46
47
    ExceptionCode ec = 0;
47
48
    unsigned newLength = 0;
48
 
    double lengthValue = value->getNumber();
49
 
    if (!isNaN(lengthValue) && !isInf(lengthValue)) {
 
49
    double lengthValue = value->toNumber(exec);
 
50
    if (!isnan(lengthValue) && !isinf(lengthValue)) {
50
51
        if (lengthValue < 0.0)
51
52
            ec = INDEX_SIZE_ERR;
52
53
        else if (lengthValue > static_cast<double>(UINT_MAX))
59
60
    setDOMException(exec, ec);
60
61
}
61
62
 
62
 
void JSHTMLOptionsCollection::indexSetter(KJS::ExecState* exec, unsigned index, KJS::JSValue* value, int attr)
 
63
void JSHTMLOptionsCollection::indexSetter(ExecState* exec, unsigned index, JSValue* value)
63
64
{
64
65
    HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
65
66
    HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->base());
66
67
    selectIndexSetter(base, exec, index, value);
67
68
}
68
69
 
 
70
JSValue* JSHTMLOptionsCollection::add(ExecState* exec, const List& args)
 
71
{
 
72
    HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
 
73
    HTMLOptionElement* option = toHTMLOptionElement(args[0]);
 
74
    ExceptionCode ec = 0;
 
75
    if (args.size() < 2)
 
76
        imp->add(option, ec);
 
77
    else {
 
78
        bool ok;
 
79
        int index = args[1]->toInt32(exec, ok);
 
80
        if (exec->hadException())
 
81
            return jsUndefined();
 
82
        if (!ok)
 
83
            ec = TYPE_MISMATCH_ERR;
 
84
        else
 
85
            imp->add(option, index, ec);
 
86
    }
 
87
    setDOMException(exec, ec);
 
88
    return jsUndefined();
 
89
}
 
90
 
 
91
JSValue* JSHTMLOptionsCollection::remove(ExecState* exec, const List& args)
 
92
{
 
93
    HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
 
94
    JSHTMLSelectElement* base = static_cast<JSHTMLSelectElement*>(toJS(exec, imp->base()));
 
95
    return base->remove(exec, args);
 
96
}
 
97
 
69
98
}