Commit 13520690579796390531d4d1ed9f88ccf6b9cf53

Authored by Perry Werneck
2 parents 04045b1a 0f3c2c45

Merge branch 'master' into CVE-2019-15525

@@ -116,9 +116,6 @@ @@ -116,9 +116,6 @@
116 <Unit filename="src/core/keyboard/properties.c"> 116 <Unit filename="src/core/keyboard/properties.c">
117 <Option compilerVar="CC" /> 117 <Option compilerVar="CC" />
118 </Unit> 118 </Unit>
119 - <Unit filename="src/core/linkelist.c">  
120 - <Option compilerVar="CC" />  
121 - </Unit>  
122 <Unit filename="src/core/linux/connect.c"> 119 <Unit filename="src/core/linux/connect.c">
123 <Option compilerVar="CC" /> 120 <Option compilerVar="CC" />
124 </Unit> 121 </Unit>
src/core/linkedlist.c 0 → 100644
@@ -0,0 +1,143 @@ @@ -0,0 +1,143 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como linkedlist.c e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 +
  31 +/**
  32 + * @brief Handle linked lists.
  33 + */
  34 +
  35 + #include <lib3270.h>
  36 + #include <lib3270/log.h>
  37 + #include <linkedlist.h>
  38 + #include <string.h>
  39 +
  40 +/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
  41 +
  42 +void * lib3270_linked_list_append_node(struct lib3270_linked_list_head *head, size_t szBlock, void *userdata)
  43 +{
  44 + struct lib3270_linked_list_node * node = lib3270_malloc(szBlock);
  45 +
  46 + memset(node,0,szBlock);
  47 + node->userdata = userdata;
  48 +
  49 + if(head->last)
  50 + {
  51 + head->last->next = node;
  52 + node->prev = head->last;
  53 + }
  54 + else
  55 + {
  56 + head->first = node;
  57 + }
  58 +
  59 + head->last = node;
  60 +
  61 + /*
  62 +#ifdef DEBUG
  63 + {
  64 + struct lib3270_linked_list_node * dCurrent;
  65 +
  66 + debug("%s: head=%p first=%p last=%p", __FUNCTION__, head, head->first, head->last);
  67 +
  68 + for(dCurrent = head->first; dCurrent; dCurrent = dCurrent->next)
  69 + {
  70 + debug("node=%p prev=%p next=%p",dCurrent,dCurrent->prev,dCurrent->next);
  71 + }
  72 +
  73 + }
  74 +#endif // DEBUG
  75 + */
  76 +
  77 + return (void *) node;
  78 +
  79 +}
  80 +
  81 +int lib3270_linked_list_delete_node(struct lib3270_linked_list_head *head, const void *node)
  82 +{
  83 +
  84 + struct lib3270_linked_list_node * current;
  85 +
  86 + for(current = head->first;current;current = current->next)
  87 + {
  88 +
  89 + if(current == node)
  90 + {
  91 +
  92 + if(current->prev)
  93 + current->prev->next = current->next;
  94 + else
  95 + head->first = current->next;
  96 +
  97 + if(current->next)
  98 + current->next->prev = current->prev;
  99 + else
  100 + head->last = current->prev;
  101 +
  102 + lib3270_free(current);
  103 +
  104 + /*
  105 +#ifdef DEBUG
  106 + {
  107 + struct lib3270_linked_list_node * dCurrent;
  108 +
  109 + debug("%s: head=%p first=%p last=%p", __FUNCTION__, head, head->first, head->last);
  110 +
  111 + for(dCurrent = head->first; dCurrent; dCurrent = dCurrent->next)
  112 + {
  113 + debug("node=%p prev=%p next=%p",dCurrent,dCurrent->prev,dCurrent->next);
  114 + }
  115 +
  116 + }
  117 +#endif // DEBUG
  118 + */
  119 +
  120 + return 0;
  121 +
  122 + }
  123 +
  124 + }
  125 +
  126 + return errno = ENOENT;
  127 +}
  128 +
  129 +void lib3270_linked_list_free(struct lib3270_linked_list_head *head)
  130 +{
  131 + struct lib3270_linked_list_node * node = head->first;
  132 +
  133 + while(node)
  134 + {
  135 + void * ptr = (void *) node;
  136 + node = node->next;
  137 + lib3270_free(ptr);
  138 + }
  139 +
  140 + head->first = head->last = NULL;
  141 +
  142 +}
  143 +
src/core/linkelist.c
@@ -1,139 +0,0 @@ @@ -1,139 +0,0 @@
1 -/*  
2 - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270  
3 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a  
4 - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.  
5 - *  
6 - * Copyright (C) <2008> <Banco do Brasil S.A.>  
7 - *  
8 - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob  
9 - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela  
10 - * Free Software Foundation.  
11 - *  
12 - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER  
13 - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO  
14 - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para  
15 - * obter mais detalhes.  
16 - *  
17 - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este  
18 - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
20 - *  
21 - * Este programa está nomeado como linkedlist.c e possui - linhas de código.  
22 - *  
23 - * Contatos:  
24 - *  
25 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
26 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
27 - *  
28 - */  
29 -  
30 -  
31 -/**  
32 - * @brief Handle linked lists.  
33 - */  
34 -  
35 - #include <lib3270.h>  
36 - #include <lib3270/log.h>  
37 - #include <linkedlist.h>  
38 - #include <string.h>  
39 -  
40 -/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/  
41 -  
42 -void * lib3270_linked_list_append_node(struct lib3270_linked_list_head *head, size_t szBlock, void *userdata)  
43 -{  
44 - struct lib3270_linked_list_node * node = lib3270_malloc(szBlock);  
45 -  
46 - memset(node,0,szBlock);  
47 - node->userdata = userdata;  
48 -  
49 - if(head->last)  
50 - {  
51 - head->last->next = node;  
52 - node->prev = head->last;  
53 - }  
54 - else  
55 - {  
56 - head->first = node;  
57 - }  
58 -  
59 - head->last = node;  
60 -  
61 -#ifdef DEBUG  
62 - {  
63 - struct lib3270_linked_list_node * dCurrent;  
64 -  
65 - debug("%s: head=%p first=%p last=%p", __FUNCTION__, head, head->first, head->last);  
66 -  
67 - for(dCurrent = head->first; dCurrent; dCurrent = dCurrent->next)  
68 - {  
69 - debug("node=%p prev=%p next=%p",dCurrent,dCurrent->prev,dCurrent->next);  
70 - }  
71 -  
72 - }  
73 -#endif // DEBUG  
74 -  
75 - return (void *) node;  
76 -  
77 -}  
78 -  
79 -int lib3270_linked_list_delete_node(struct lib3270_linked_list_head *head, const void *node)  
80 -{  
81 -  
82 - struct lib3270_linked_list_node * current;  
83 -  
84 - for(current = head->first;current;current = current->next)  
85 - {  
86 -  
87 - if(current == node)  
88 - {  
89 -  
90 - if(current->prev)  
91 - current->prev->next = current->next;  
92 - else  
93 - head->first = current->next;  
94 -  
95 - if(current->next)  
96 - current->next->prev = current->prev;  
97 - else  
98 - head->last = current->prev;  
99 -  
100 - lib3270_free(current);  
101 -  
102 -#ifdef DEBUG  
103 - {  
104 - struct lib3270_linked_list_node * dCurrent;  
105 -  
106 - debug("%s: head=%p first=%p last=%p", __FUNCTION__, head, head->first, head->last);  
107 -  
108 - for(dCurrent = head->first; dCurrent; dCurrent = dCurrent->next)  
109 - {  
110 - debug("node=%p prev=%p next=%p",dCurrent,dCurrent->prev,dCurrent->next);  
111 - }  
112 -  
113 - }  
114 -#endif // DEBUG  
115 -  
116 - return 0;  
117 -  
118 - }  
119 -  
120 - }  
121 -  
122 - return errno = ENOENT;  
123 -}  
124 -  
125 -void lib3270_linked_list_free(struct lib3270_linked_list_head *head)  
126 -{  
127 - struct lib3270_linked_list_node * node = head->first;  
128 -  
129 - while(node)  
130 - {  
131 - void * ptr = (void *) node;  
132 - node = node->next;  
133 - lib3270_free(ptr);  
134 - }  
135 -  
136 - head->first = head->last = NULL;  
137 -  
138 -}  
139 -