summaryrefslogtreecommitdiff
path: root/noncore/todayplugins
authorerik <erik>2007-01-24 19:54:07 (UTC)
committer erik <erik>2007-01-24 19:54:07 (UTC)
commit89e81059e832ff77c2f0ac8b9db12f80eafa03fc (patch) (unidiff)
tree99a130fc643d2aeefdecab452f644e7b61a5f50e /noncore/todayplugins
parent035bbc5bf689839c8d8e7be37f347b0dd900fccf (diff)
downloadopie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.zip
opie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.tar.gz
opie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.tar.bz2
Each file in this commit has an instance where a pointer is checked at
one point in the code and then not checked in another point in the code. If it needed to be checked once, it needs to be checked the other time. If not the application could segfault.
Diffstat (limited to 'noncore/todayplugins') (more/less context) (show whitespace changes)
-rw-r--r--noncore/todayplugins/stockticker/libstocks/http.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/todayplugins/stockticker/libstocks/http.c b/noncore/todayplugins/stockticker/libstocks/http.c
index 2f38f8a..cc78ab7 100644
--- a/noncore/todayplugins/stockticker/libstocks/http.c
+++ b/noncore/todayplugins/stockticker/libstocks/http.c
@@ -165,97 +165,97 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata)
165 { 165 {
166 if((data = malloc(r+1))==NULL) 166 if((data = malloc(r+1))==NULL)
167 { 167 {
168 fprintf(stderr,"Memory allocating error (%s line %d)\n" 168 fprintf(stderr,"Memory allocating error (%s line %d)\n"
169 ,__FILE__, __LINE__); 169 ,__FILE__, __LINE__);
170 exit(1); 170 exit(1);
171 } 171 }
172 172
173 memcpy(data,buf,r); 173 memcpy(data,buf,r);
174 data_lgr = r; 174 data_lgr = r;
175 data[r]=0; 175 data[r]=0;
176 } 176 }
177 else 177 else
178 { 178 {
179 if((temp = malloc(r+data_lgr+1))==NULL) 179 if((temp = malloc(r+data_lgr+1))==NULL)
180 { 180 {
181 fprintf(stderr,"Memory allocating error (%s line %d)\n" 181 fprintf(stderr,"Memory allocating error (%s line %d)\n"
182 ,__FILE__, __LINE__); 182 ,__FILE__, __LINE__);
183 exit(1); 183 exit(1);
184 } 184 }
185 memcpy(temp, data, data_lgr); 185 memcpy(temp, data, data_lgr);
186 memcpy(temp+data_lgr, buf, r); 186 memcpy(temp+data_lgr, buf, r);
187 temp[r+data_lgr]=0; 187 temp[r+data_lgr]=0;
188 data_lgr += r; 188 data_lgr += r;
189 free(data); 189 free(data);
190 data = temp; 190 data = temp;
191 } 191 }
192 } 192 }
193 } 193 }
194 194
195 /* close socket */ 195 /* close socket */
196#ifdef __UNIX__ 196#ifdef __UNIX__
197 close(s); 197 close(s);
198#elif __WINDOWS__ 198#elif __WINDOWS__
199 closesocket(s); 199 closesocket(s);
200#endif 200#endif
201 201
202#ifdef DEBUG 202#ifdef DEBUG
203 printf("%s\n", data); 203 printf("%s\n", data);
204#endif 204#endif
205 205
206 /* get headers to test status line */ 206 /* get headers to test status line */
207 /* and to split headers and content */ 207 /* and to split headers and content */
208 208
209 temp = data; 209 temp = data;
210 header_founded = 0; 210 header_founded = 0;
211 while( !header_founded ) 211 while( !header_founded )
212 { 212 {
213 if (*temp==0) return ERRRHEA; 213 if (!temp || *temp==0) return ERRRHEA;
214 214
215 if( *temp==0x0A ) 215 if( *temp==0x0A )
216 { 216 {
217 /* test if it is the header end */ 217 /* test if it is the header end */
218 temp ++; 218 temp ++;
219 if (*temp == 0x0D) temp++; 219 if (*temp == 0x0D) temp++;
220 if (*temp == 0x0A) header_founded = 1; 220 if (*temp == 0x0A) header_founded = 1;
221 } 221 }
222 else 222 else
223 temp++; 223 temp++;
224 } 224 }
225 225
226 *temp = 0; 226 *temp = 0;
227 temp++; 227 temp++;
228 228
229 sscanf(data,"HTTP/1.%*d %03d",&error_code); 229 sscanf(data,"HTTP/1.%*d %03d",&error_code);
230 230
231 if (error_code != 200) 231 if (error_code != 200)
232 { 232 {
233#ifdef DEBUG 233#ifdef DEBUG
234 printf(" HTTP error code : %d\n", error_code); 234 printf(" HTTP error code : %d\n", error_code);
235#endif 235#endif
236 free(data); 236 free(data);
237 return ERRPAHD; 237 return ERRPAHD;
238 } 238 }
239 239
240 if ((csv_ptr = malloc(strlen(temp)+1))==NULL) 240 if ((csv_ptr = malloc(strlen(temp)+1))==NULL)
241 { 241 {
242 free(data); 242 free(data);
243 fprintf(stderr,"Memory allocating error (%s line %d)\n" 243 fprintf(stderr,"Memory allocating error (%s line %d)\n"
244 ,__FILE__, __LINE__); 244 ,__FILE__, __LINE__);
245 exit(1); 245 exit(1);
246 } 246 }
247 247
248 memcpy(csv_ptr, temp, strlen(temp)+1); 248 memcpy(csv_ptr, temp, strlen(temp)+1);
249 free(data); 249 free(data);
250 250
251#ifdef DEBUG 251#ifdef DEBUG
252 printf(" CSV\n"); 252 printf(" CSV\n");
253 printf("%s,\n", csv_ptr); 253 printf("%s,\n", csv_ptr);
254#endif 254#endif
255 255
256 *pdata = csv_ptr; 256 *pdata = csv_ptr;
257 257
258 return 0; 258 return 0;
259} 259}
260 260
261/******************************************************************************/ 261/******************************************************************************/