Mercurial > pidgin
comparison src/toc.c @ 79:bfdc427b936d
[gaim-migrate @ 89]
I'll save time and just post the email :-)
Summary of changes:
* Misc malloc/free cleanups, use g_malloc more places and
other small stuff (e.g. lineardata not being freed in the
error case in sound.c)
* Misc signed/unsigned cleanups (use size_t more often)
* read() can return -1 at any point, check return values
more rigorously (read_rv variables used for this)
* In can_play_audio, stat requires a pointer to an
allocated stat_buf (the address of an automatic variable)
* escape_text needs a buffer at least 4 times the size of
the text being passed in (not 2 times); I can force core
dumps with lots of newlines otherwise
* There's a debug statement in netscape_command
(browser.c) that was printf("Hello%d\n"); with no int for
the %d; I threw in a getppid(), but the statement should
probably come out eventually.
Thanks, G Sumner Hayes!
committer: Tailor Script <tailor@pidgin.im>
| author | Rob Flynn <gaim@robflynn.com> |
|---|---|
| date | Wed, 05 Apr 2000 05:34:08 +0000 |
| parents | aa738bb8d8d7 |
| children | 55faf2e3a134 |
comparison
equal
deleted
inserted
replaced
| 78:66c5a24b62ec | 79:bfdc427b936d |
|---|---|
| 281 | 281 |
| 282 return write(toc_fd, obuf, slen); | 282 return write(toc_fd, obuf, slen); |
| 283 } | 283 } |
| 284 | 284 |
| 285 | 285 |
| 286 int wait_reply(char *buffer, int buflen) | 286 int wait_reply(char *buffer, size_t buflen) |
| 287 { | 287 { |
| 288 int res=6; | 288 size_t res=-1; |
| 289 int read_rv = -1; | |
| 289 struct sflap_hdr *hdr=(struct sflap_hdr *)buffer; | 290 struct sflap_hdr *hdr=(struct sflap_hdr *)buffer; |
| 290 char *c; | 291 char *c; |
| 291 | 292 |
| 292 while((res = read(toc_fd, buffer, 1))) { | 293 if(buflen < sizeof(struct sflap_hdr)) { |
| 293 if (res < 0) | 294 do_error_dialog("Buffer too small", "Gaim - Error (internal)"); |
| 294 return res; | 295 return -1; |
| 296 } | |
| 297 | |
| 298 while((read_rv = read(toc_fd, buffer, 1))) { | |
| 299 if (read_rv < 0 || read_rv > 1) | |
| 300 return -1; | |
| 295 if (buffer[0] == '*') | 301 if (buffer[0] == '*') |
| 296 break; | 302 break; |
| 297 | 303 |
| 298 } | 304 } |
| 299 | 305 |
| 300 res = read(toc_fd, buffer+1, sizeof(struct sflap_hdr) - 1); | 306 read_rv = read(toc_fd, buffer+1, sizeof(struct sflap_hdr) - 1); |
| 301 | 307 |
| 302 if (res < 0) | 308 if (read_rv < 0) |
| 303 return res; | 309 return read_rv; |
| 304 | 310 |
| 305 res += 1; | 311 res = read_rv + 1; |
| 306 | 312 |
| 307 | 313 |
| 308 sprintf(debug_buff, "Rcv: %s %s\n",print_header(buffer), ""); | 314 sprintf(debug_buff, "Rcv: %s %s\n",print_header(buffer), ""); |
| 309 debug_print(debug_buff); | 315 debug_print(debug_buff); |
| 310 | 316 |
| 311 | 317 |
| 318 if(buflen < sizeof(struct sflap_hdr) + ntohs(hdr->len) + 1) { | |
| 319 do_error_dialog("Buffer too small", "Gaim - Error (internal)"); | |
| 320 return -1; | |
| 321 } | |
| 312 | 322 |
| 313 while (res < (sizeof(struct sflap_hdr) + ntohs(hdr->len))) { | 323 while (res < (sizeof(struct sflap_hdr) + ntohs(hdr->len))) { |
| 314 res += read(toc_fd, buffer + res, (ntohs(hdr->len) + sizeof(struct sflap_hdr)) - res); | 324 read_rv = read(toc_fd, buffer + res, (ntohs(hdr->len) + sizeof(struct sflap_hdr)) - res); |
| 325 if(read_rv < 0) return read_rv; | |
| 326 res += read_rv; | |
| 315 while(gtk_events_pending()) | 327 while(gtk_events_pending()) |
| 316 gtk_main_iteration(); | 328 gtk_main_iteration(); |
| 317 } | 329 } |
| 318 | 330 |
| 319 if (res >= sizeof(struct sflap_hdr)) | 331 if (res >= sizeof(struct sflap_hdr)) |
