Changeset 4220 for trunk/lib-src/pop.c
- Timestamp:
- 04/04/08 22:04:40 (8 months ago)
- Files:
-
- trunk/lib-src/pop.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib-src/pop.c
r4190 r4220 1 1 /* pop.c: client routines for talking to a POP3-protocol post-office server 2 2 Copyright (C) 1991, 1993, 1996, 1997, 1999, 2001, 2002, 2003, 2004, 3 2005, 2006, 2007 Free Software Foundation, Inc.3 2005, 2006, 2007, 2008 Free Software Foundation, Inc. 4 4 Written by Jonathan Kamens, jik@security.ov.com. 5 5 … … 8 8 GNU Emacs is free software; you can redistribute it and/or modify 9 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2, or (at your option)10 the Free Software Foundation; either version 3, or (at your option) 11 11 any later version. 12 12 … … 353 353 { 354 354 char *fromserver; 355 char *end_ptr; 355 356 356 357 if (server->in_multi) … … 378 379 } 379 380 380 *count = atoi (&fromserver[4]); 381 382 fromserver = index (&fromserver[4], ' '); 383 if (! fromserver) 384 { 385 strcpy (pop_error, 386 "Badly formatted response from server in pop_stat"); 381 errno = 0; 382 *count = strtol (&fromserver[4], &end_ptr, 10); 383 /* Check validity of string-to-integer conversion. */ 384 if (fromserver + 4 == end_ptr || *end_ptr != ' ' || errno) 385 { 386 strcpy (pop_error, "Unexpected response from POP server in pop_stat"); 387 387 pop_trash (server); 388 388 return (-1); 389 389 } 390 390 391 *size = atoi (fromserver + 1); 391 fromserver = end_ptr; 392 393 errno = 0; 394 *size = strtol (fromserver + 1, &end_ptr, 10); 395 if (fromserver + 1 == end_ptr || errno) 396 { 397 strcpy (pop_error, "Unexpected response from POP server in pop_stat"); 398 pop_trash (server); 399 return (-1); 400 } 392 401 393 402 return (0); … … 914 923 else 915 924 { 916 return (atoi (&fromserver[4])); 925 char *end_ptr; 926 int count; 927 errno = 0; 928 count = strtol (&fromserver[4], &end_ptr, 10); 929 if (fromserver + 4 == end_ptr || errno) 930 { 931 strcpy (pop_error, "Unexpected response from server in pop_last"); 932 pop_trash (server); 933 return (-1); 934 } 935 return count; 917 936 } 918 937 } … … 1558 1577 * 1559 1578 * Purpose: Like pop_close or pop_quit, but doesn't deallocate the 1560 * memory associated with the server. It is legalto call1579 * memory associated with the server. It is valid to call 1561 1580 * pop_close or pop_quit after this function has been called. 1562 1581 */
