Show
Ignore:
Timestamp:
04/04/08 22:04:40 (8 months ago)
Author:
miyoshi
Message:

Sync up with Emacs22.2.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib-src/pop.c

    r4190 r4220  
    11/* pop.c: client routines for talking to a POP3-protocol post-office server 
    22   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. 
    44   Written by Jonathan Kamens, jik@security.ov.com. 
    55 
     
    88GNU Emacs is free software; you can redistribute it and/or modify 
    99it under the terms of the GNU General Public License as published by 
    10 the Free Software Foundation; either version 2, or (at your option) 
     10the Free Software Foundation; either version 3, or (at your option) 
    1111any later version. 
    1212 
     
    353353{ 
    354354  char *fromserver; 
     355  char *end_ptr; 
    355356 
    356357  if (server->in_multi) 
     
    378379    } 
    379380 
    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"); 
    387387      pop_trash (server); 
    388388      return (-1); 
    389389    } 
    390390 
    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    } 
    392401 
    393402  return (0); 
     
    914923  else 
    915924    { 
    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; 
    917936    } 
    918937} 
     
    15581577 * 
    15591578 * Purpose: Like pop_close or pop_quit, but doesn't deallocate the 
    1560  *      memory associated with the server.  It is legal to call 
     1579 *      memory associated with the server.  It is valid to call 
    15611580 *      pop_close or pop_quit after this function has been called. 
    15621581 */