all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* some code issues
@ 2008-01-05 17:59 Nico Golde
  2008-01-08 21:26 ` Thien-Thi Nguyen
  0 siblings, 1 reply; 2+ messages in thread
From: Nico Golde @ 2008-01-05 17:59 UTC (permalink / raw)
  To: bug-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1678 bytes --]

Hi,
I had a quick look at the pop.c code today and found some 
issues.

In pop_stat:

365   if (strncmp (fromserver, "+OK ", 4))
366     {
367       if (0 == strncmp (fromserver, "-ERR", 4))
368    {
369      strncpy (pop_error, fromserver, ERROR_MAX);
370    }
371      else
372    {
373      strcpy (pop_error,
374    >···  "Unexpected response from POP server in pop_stat");
375      pop_trash (server);
376    }
377       return (-1);
378     }

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");
387       pop_trash (server);
388       return (-1);
389     }

If I don't miss anything the atoi call in 380 is not save as it is not 
save because it is not ensure that &fromserver[4] is not NULL. A crafted
pop3 server could thus crash emacs. This is of course not a real issue but
wouldn't be nice. Same for the pop_last function.

In pop_list:

440 
441   *IDs = (int *) malloc ((how_many + 1) * sizeof (int));
442   *sizes = (int *) malloc ((how_many + 1) * sizeof (int));
443   if (! (*IDs && *sizes))
444     {
445       strcpy (pop_error, "Out of memory in pop_list");
446       return (-1);
447     }
448 

in 441 and 442 there should be some check for how_many to prevent an integer
overflow here.
Same problem for the xnew macro in etags.c

What do you think about this?
Kind regards
Nico
-- 
Nico Golde - http://www.ngolde.de - nion@jabber.ccc.de - GPG: 0x73647CFF
For security reasons, all text in this mail is double-rot13 encrypted.

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: some code issues
  2008-01-05 17:59 some code issues Nico Golde
@ 2008-01-08 21:26 ` Thien-Thi Nguyen
  0 siblings, 0 replies; 2+ messages in thread
From: Thien-Thi Nguyen @ 2008-01-08 21:26 UTC (permalink / raw)
  To: Nico Golde; +Cc: bug-gnu-emacs

() Nico Golde <nico@ngolde.de>
() Sat, 5 Jan 2008 18:59:08 +0100

   [strcpy use]

   What do you think about this?

i think i would be happy to apply a well-written and legally-clear
patch that checks for strange situations and handles them.

would you like to write that?

thi




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-01-08 21:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-05 17:59 some code issues Nico Golde
2008-01-08 21:26 ` Thien-Thi Nguyen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.