delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/06/12:30:31

From: Michiel Uitdehaag <m DOT uitdehaag AT imn DOT nl>
Newsgroups: comp.os.msdos.djgpp
Subject: libsocket resit demo
Date: Thu, 06 Aug 1998 17:57:44 +0200
Organization: World Online
Lines: 39
Message-ID: <35C9D278.E1889095@imn.nl>
NNTP-Posting-Host: pc007.wkap.nl
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi,

I installed the Libsocket TCP library yesterday (from the
http://www.geocities.com/SiliconValley/Lab/3216/lsck.htm libsocket
pages) and noticed the resit demo crashing every time.
So, being the newbie I am and investigating the c code, I found this:
(resit.c)

int main (int argc, char *argv[])
{
 struct hostent *hpke;
 char *x;

... (snip)

printf ("Aliases: ");
  while ( *(hpke->h_aliases ) ) {
    printf ("%s ", *hpke->h_aliases );    <-----------Here
    hpke->h_aliases ++;
  }

... <snip rest>

as hpke is already a pointer, *hpke would dereference it, and force the
program to use the value at (*hpke) as a pointer to h_aliases, or am I
gravely mistaking here?
Shouldn't the correct code be:

printf ("Aliases: ");
  while ( *(hpke->h_aliases ) ) {
    printf ("%s ", hpke->h_aliases );
    hpke->h_aliases ++;
  }

My apologies if this has been signalled before,

Michiel Uitdehaag


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019