~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/erl_interface/src/misc/ei_decode_term.c

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * %CopyrightBegin%
3
 
 * 
4
 
 * Copyright Ericsson AB 2001-2009. All Rights Reserved.
5
 
 * 
 
3
 *
 
4
 * Copyright Ericsson AB 2001-2011. All Rights Reserved.
 
5
 *
6
6
 * The contents of this file are subject to the Erlang Public License,
7
7
 * Version 1.1, (the "License"); you may not use this file except in
8
8
 * compliance with the License. You should have received a copy of the
9
9
 * Erlang Public License along with this software. If not, it can be
10
10
 * retrieved online at http://www.erlang.org/.
11
 
 * 
 
11
 *
12
12
 * Software distributed under the License is distributed on an "AS IS"
13
13
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
 * the License for the specific language governing rights and limitations
15
15
 * under the License.
16
 
 * 
 
16
 *
17
17
 * %CopyrightEnd%
18
18
 *
19
19
 
25
25
#include "ei_decode_term.h"
26
26
#include "putget.h"
27
27
 
28
 
/* Returns 1 if term is decoded, 0 if term is OK, but not decoded here
29
 
   and -1 if something is wrong.
30
 
   ONLY changes index if term is decoded (return value 1)! */
 
28
/* Returns 0 on successful encoding, -1 on error, and 1 if the term seems
 
29
   alright, but does not fit in the term structure. If it returns 0, the
 
30
   index will be incremented, and the term contains the decoded term. */
31
31
 
32
32
int ei_decode_ei_term(const char* buf, int* index, ei_term* term)
33
33
{
34
34
    const char* s = buf + *index, * s0 = s;
35
35
    int len, i, n, sign;
36
36
    char c;
37
 
    double f;
38
37
 
39
38
    if (term == NULL) return -1;
40
39
    c = term->ei_type = get8(s);
46
45
        term->value.i_val = get32be(s);
47
46
        break;
48
47
    case ERL_FLOAT_EXT:
49
 
        if (s[30]) return -1;
50
 
        if (sscanf(s, "%lf", &f) != 1) return -1;
51
 
        s += 31;
52
 
        term->value.d_val = f;
53
 
        break;
 
48
    case NEW_FLOAT_EXT:
 
49
        return ei_decode_double(buf, index, &term->value.d_val);
54
50
    case ERL_ATOM_EXT:
55
51
        len = get16be(s);
 
52
        if (len > MAXATOMLEN) return -1;
56
53
        memcpy(term->value.atom_name, s, len); 
57
54
        term->value.atom_name[len] = '\0';
58
55
        s += len;
61
58
        /* first the nodename */
62
59
        if (get8(s) != ERL_ATOM_EXT) return -1;
63
60
        len = get16be(s);
 
61
        if (len > MAXATOMLEN) return -1;
64
62
        memcpy(term->value.ref.node, s, len);
65
63
        term->value.ref.node[len] = '\0';
66
64
        s += len;
75
73
        /* then the nodename */
76
74
        if (get8(s) != ERL_ATOM_EXT) return -1;
77
75
        len = get16be(s);
 
76
        if (len > MAXATOMLEN) return -1;
78
77
        memcpy(term->value.ref.node, s, len);
79
78
        term->value.ref.node[len] = '\0';
80
79
        s += len;
91
90
    case ERL_PORT_EXT:
92
91
        if (get8(s) != ERL_ATOM_EXT) return -1;
93
92
        len = get16be(s);
 
93
        if (len > MAXATOMLEN) return -1;
94
94
        memcpy(term->value.port.node, s, len);
95
95
        term->value.port.node[len] = '\0';
96
96
        term->value.port.id = get32be(s) & 0x0fffffff; /* 28 bits */;
100
100
        if (get8(s) != ERL_ATOM_EXT) return -1;
101
101
        /* name first */
102
102
        len = get16be(s); 
 
103
        if (len > MAXATOMLEN) return -1;
103
104
        memcpy(term->value.pid.node, s, len);
104
105
        term->value.pid.node[len] = '\0';
105
106
        s += len;