This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c/9557: gcc 2.95.3 20010315 (SuSE) problem with place of variable


Synopsis: gcc  2.95.3 20010315 (SuSE) problem with place of variable

State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Mon Feb  3 23:42:38 2003
State-Changed-Why:
    User error -- read sscanf man page:
    -----------------------
      struct lien *con;
      short  port;
        
      con=(struct lien *)malloc(sizeof(struct lien));
      sscanf(n_service, "%d", &port);
      con->adr4.sin_port =1;
    --------------------------
    Using a short with %d is bound to write beyond its bounds.
    You overwrite the value of the con pointer, which afterwards
    points to no-go land. Use an integer with %d and your
    program works again. The fact that it worked by exchanging
    variable declarations just means that instead of the con
    pointer, you overwrote the ok flag.
    
    W.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9557


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]