Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 232581
Collapse All | Expand All

(-)suck-4.3.2.orig/active.c (-2 / +1 lines)
Lines 181-187 Link Here
181
	
181
	
182
	/* connect to localhost NNTP server */
182
	/* connect to localhost NNTP server */
183
	int fd;
183
	int fd;
184
	struct hostent *hi;
185
	char *inbuf;
184
	char *inbuf;
186
	unsigned int port;
185
	unsigned int port;
187
186
Lines 190-196 Link Here
190
		do_debug("Connecting to %s on port %d\n", master->localhost, port);
189
		do_debug("Connecting to %s on port %d\n", master->localhost, port);
191
	}
190
	}
192
	
191
	
193
	if((fd = connect_to_nntphost(master->localhost, &hi, NULL, port, master->local_ssl, &master->local_ssl_struct)) >= 0) {
192
	if((fd = connect_to_nntphost(master->localhost, NULL, 0, NULL, port, master->local_ssl, &master->local_ssl_struct)) >= 0) {
194
		/* get the announcement line */
193
		/* get the announcement line */
195
		if(sgetline(fd, &inbuf, master->local_ssl, master->local_ssl_struct) < 0) {
194
		if(sgetline(fd, &inbuf, master->local_ssl, master->local_ssl_struct) < 0) {
196
			close(fd);
195
			close(fd);
(-)suck-4.3.2.orig/both.c (-81 / +54 lines)
Lines 138-172 Link Here
138
	return retval;
138
	return retval;
139
}
139
}
140
140
141
/*---------------------------------------------*/
142
struct hostent *get_hostent(const char *host) {
143
	struct in_addr saddr;
144
	int c;
145
	struct hostent *hi = NULL;
146
147
	if(host==NULL) { 
148
		error_log(ERRLOG_REPORT,both_phrases[0], NULL); 
149
	}
150
	else {
151
		c=*host;
152
		if(isdigit(c)) {
153
 			saddr.s_addr = inet_addr(host); 
154
 			hi = gethostbyaddr((char *)&saddr,sizeof(struct in_addr),AF_INET);
155
		}
156
		else {
157
			hi = gethostbyname(host);
158
		}
159
	}
160
	return hi;
161
}
162
/*--------------------------------------------*/
141
/*--------------------------------------------*/
163
int connect_to_nntphost(const char *host, struct hostent **hi, FILE *msgs, unsigned short int portnr, int do_ssl, void **ssl) {
142
int connect_to_nntphost(const char *host, char *hname, size_t hnlength, FILE *msgs, unsigned short int portnr, int do_ssl, void **ssl)
164
	char *ptr, *realhost;
143
{
165
	struct in_addr *aptr;
144
	char *realhost, *pport;
166
	struct in_addr saddr;
167
	struct sockaddr_in address;
168
	char sport[10];
145
	char sport[10];
169
	int sockfd = -1;
146
	struct addrinfo *l, hint = { 0 };
147
	int r, sockfd = -1;
170
	
148
	
171
#ifdef HAVE_LIBSSL
149
#ifdef HAVE_LIBSSL
172
	SSL *ssl_struct = NULL;
150
	SSL *ssl_struct = NULL;
Lines 184-248 Link Here
184
	}
162
	}
185
#endif
163
#endif
186
	/* handle host:port type syntax */
164
	/* handle host:port type syntax */
187
	realhost = strdup(host);
165
	realhost = alloca(strlen(host) + 1);
188
	if(realhost == NULL) {
166
	strcpy(realhost, host);
189
		MyPerror("out of memory copying host name");
167
	pport = strchr(realhost, ':');
190
		return sockfd;
168
	if(pport != NULL) {
191
	}
169
		*pport = '\0';	/* null terminate host name */
192
	ptr = strchr(realhost, ':');
170
		++pport;	/* get port number */
193
	if(ptr != NULL) {
171
	}
194
		*ptr = '\0';  /* null terminate host name */
172
	else
195
		portnr = atoi(++ptr); /* get port number */
173
	{
196
	}
174
		snprintf(sport, sizeof(sport), "%hu", portnr);	/* cause print_phrases wants all strings */
197
	
175
		pport = sport;
198
	
176
	}
199
	
177
	print_phrases(msgs, both_phrases[1], pport, NULL);
200
	sprintf(sport, "%hu", portnr);	/* cause print_phrases wants all strings */
178
	hint.ai_socktype = SOCK_STREAM;
201
	print_phrases(msgs, both_phrases[1], sport, NULL);
179
	hint.ai_flags = AI_ADDRCONFIG | AI_CANONNAME;
202
180
	r = getaddrinfo(realhost, pport, &hint, &l);
203
	/* Find the internet address of the NNTP server */
181
	if(r != 0 || l == NULL)
204
 	*hi = get_hostent(realhost);
182
	{
205
 	if(*hi == NULL) {
206
		error_log(ERRLOG_REPORT,"%v1%: ",realhost, NULL);
183
		error_log(ERRLOG_REPORT,"%v1%: ",realhost, NULL);
207
  		MyPerror(both_phrases[2]);
184
  		MyPerror(both_phrases[2]);
208
		free(realhost);
209
 	}
185
 	}
210
	else {
186
	else
211
		free(realhost);
187
	{
212
		print_phrases(msgs, both_phrases[3], (*hi)->h_name, NULL);
188
		struct addrinfo *p = l;
213
 		while((ptr = *((*hi)->h_aliases)) != NULL) {
189
		print_phrases(msgs, both_phrases[3], p->ai_canonname, NULL);
214
			print_phrases(msgs, both_phrases[4], ptr, NULL );
190
                if((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1)
215
			(*hi)->h_aliases++;
191
		{
216
		}
192
            		MyPerror(both_phrases[6]);
217
 		if((*hi)->h_addrtype != AF_INET) {
193
                }
218
  			error_log(ERRLOG_REPORT, both_phrases[5], NULL);
194
                else
219
		}
195
		{
220
		else {
196
                        if(connect(sockfd, p->ai_addr, p->ai_addrlen) == -1)
221
			while((aptr = (struct in_addr *)*((*hi)->h_addr_list)++) != NULL) {
197
			{
222
				saddr = *aptr;
198
                                MyPerror(both_phrases[7]);
223
				print_phrases(msgs, both_phrases[17], inet_ntoa(*aptr), NULL);
199
                                close(sockfd);
224
			}
200
                                sockfd = -1;
225
201
                        }
226
			/* Create a socket */
202
                        else
227
 			if((sockfd = socket( AF_INET, SOCK_STREAM, SOCKET_PROTOCOL)) == -1) {
203
			{
228
				MyPerror(both_phrases[6]);
204
				char lhost[256], lport[64];
229
			}
205
				r = getnameinfo(p->ai_addr, p->ai_addrlen, lhost, sizeof(lhost),
230
			else { 
206
						lport, sizeof(lport), 0);
231
				address.sin_family = AF_INET;
207
				if(r == 0)
232
				address.sin_port = htons(portnr);  /* NNTP port */
208
				{
233
				address.sin_addr= saddr;
209
                        		print_phrases(msgs,both_phrases[8], lhost, NULL);
234
210
					if(hname && hnlength)
235
				/* Establish a connection */
211
					{
236
				if(connect(sockfd, (struct sockaddr *)&address, sizeof address ) == -1) {
212
						strncpy(hname, lhost, hnlength);
237
					MyPerror(both_phrases[7]);
213
						hname[hnlength] = '\0';
238
					close(sockfd);
214
					}
239
					sockfd = -1;
240
				}
241
				else {
242
					print_phrases(msgs,both_phrases[8], (*hi)->h_name, NULL);
243
				}
215
				}
244
			}
216
                        }
245
		}
217
		}
218
		freeaddrinfo(l);
246
#ifdef HAVE_LIBSSL
219
#ifdef HAVE_LIBSSL
247
		if(sockfd > -1 && do_ssl == TRUE) {
220
		if(sockfd > -1 && do_ssl == TRUE) {
248
			if((ssl_struct = SSL_new(test1)) == NULL) {
221
			if((ssl_struct = SSL_new(test1)) == NULL) {
(-)suck-4.3.2.orig/both.h (-1 / +1 lines)
Lines 9-15 Link Here
9
/* declarations */
9
/* declarations */
10
int sgetline(int fd, char **sbuf, int, void *);
10
int sgetline(int fd, char **sbuf, int, void *);
11
int sputline(int fd, const char *outbuf, int, void *);
11
int sputline(int fd, const char *outbuf, int, void *);
12
int connect_to_nntphost(const char *host, struct hostent **, FILE *, unsigned short int, int, void **);
12
int connect_to_nntphost(const char *host, char *hname, size_t hnlength, FILE *msgs, unsigned short int portnr, int do_ssl, void **ssl);
13
void disconnect_from_nntphost(int, int, void **);
13
void disconnect_from_nntphost(int, int, void **);
14
char *number(char *sp, int *intPtr);
14
char *number(char *sp, int *intPtr);
15
char *get_long(char *, long *);
15
char *get_long(char *, long *);
(-)suck-4.3.2.orig/rpost.c (-4 / +4 lines)
Lines 28-34 Link Here
28
#ifndef PL_na
28
#ifndef PL_na
29
# define PL_na (na)
29
# define PL_na (na)
30
#endif
30
#endif
31
#endif /* OLD_PERL */u
31
#endif /* OLD_PERL */
32
#endif
32
#endif
33
33
34
#ifdef HAVE_DIRENT_H
34
#ifdef HAVE_DIRENT_H
Lines 117-123 Link Here
117
int main(int argc, char *argv[], char *env[]) {
117
int main(int argc, char *argv[], char *env[]) {
118
	char *inbuf;
118
	char *inbuf;
119
	int response, retval, loop, fargc, i;
119
	int response, retval, loop, fargc, i;
120
	struct hostent *hi;
120
	char hname[256];
121
	struct stat sbuf;
121
	struct stat sbuf;
122
	char **args, **fargs;
122
	char **args, **fargs;
123
	Args myargs;
123
	Args myargs;
Lines 244-250 Link Here
244
			retval = RETVAL_ERROR;
244
			retval = RETVAL_ERROR;
245
		}
245
		}
246
		else {
246
		else {
247
			myargs.sockfd = connect_to_nntphost( myargs.host, &hi, myargs.status_fptr, myargs.portnr, myargs.do_ssl, &myargs.ssl_struct);
247
			myargs.sockfd = connect_to_nntphost(myargs.host, hname, sizeof(hname), myargs.status_fptr, myargs.portnr, myargs.do_ssl, &myargs.ssl_struct);
248
			if(myargs.sockfd < 0) {
248
			if(myargs.sockfd < 0) {
249
				retval = RETVAL_ERROR;
249
				retval = RETVAL_ERROR;
250
			}
250
			}
Lines 299-305 Link Here
299
				retval = do_article(&myargs, stdin);
299
				retval = do_article(&myargs, stdin);
300
			}
300
			}
301
	
301
	
302
			print_phrases(myargs.status_fptr, rpost_phrases[4], hi->h_name, NULL);
302
			print_phrases(myargs.status_fptr, rpost_phrases[4], hname, NULL);
303
			if(myargs.debug == TRUE) {
303
			if(myargs.debug == TRUE) {
304
				do_debug("Sending quit");
304
				do_debug("Sending quit");
305
			}
305
			}
(-)suck-4.3.2.orig/suck.c (-2 / +1 lines)
Lines 665-671 Link Here
665
665
666
	char *inbuf;
666
	char *inbuf;
667
	int nr, resp, retval = RETVAL_OK;
667
	int nr, resp, retval = RETVAL_OK;
668
	struct hostent *hi;
669
	FILE *fp;
668
	FILE *fp;
670
	
669
	
671
	
670
	
Lines 696-702 Link Here
696
	}
695
	}
697
	fp = (which_time == CONNECT_FIRST) ? master->msgs : NULL;
696
	fp = (which_time == CONNECT_FIRST) ? master->msgs : NULL;
698
697
699
	master->sockfd = connect_to_nntphost( master->host, &hi, fp, master->portnr, master->do_ssl, &master->ssl_struct);
698
	master->sockfd = connect_to_nntphost( master->host, NULL, 0, fp, master->portnr, master->do_ssl, &master->ssl_struct);
700
	
699
	
701
	if(master->sockfd < 0 ) {
700
	if(master->sockfd < 0 ) {
702
		retval = RETVAL_ERROR;
701
		retval = RETVAL_ERROR;
(-)suck-4.3.2.orig/testhost.c (-2 / +1 lines)
Lines 59-65 Link Here
59
int main(int argc, char *argv[]) {
59
int main(int argc, char *argv[]) {
60
60
61
	int sockfd, response, loop, cmd, quiet, mode_reader, do_ssl, retval = RETVAL_OK;
61
	int sockfd, response, loop, cmd, quiet, mode_reader, do_ssl, retval = RETVAL_OK;
62
	struct hostent *hi;
63
	struct stat sbuf;
62
	struct stat sbuf;
64
	unsigned short int portnr;
63
	unsigned short int portnr;
65
	FILE *fptr = stdout;		/* used to print output to */
64
	FILE *fptr = stdout;		/* used to print output to */
Lines 229-235 Link Here
229
	if(retval == RETVAL_OK) {
228
	if(retval == RETVAL_OK) {
230
		load_phrases(phrases);	/* this is here so everything displays okay */
229
		load_phrases(phrases);	/* this is here so everything displays okay */
231
230
232
		sockfd = connect_to_nntphost( host, &hi, (quiet == FALSE)?  fptr : NULL, portnr, do_ssl, &ssl_struct);
231
		sockfd = connect_to_nntphost(host, NULL, 0, (quiet == FALSE)?  fptr : NULL, portnr, do_ssl, &ssl_struct);
233
		if(sockfd < 0 ) {
232
		if(sockfd < 0 ) {
234
			retval = RETVAL_ERROR;
233
			retval = RETVAL_ERROR;
235
		}
234
		}

Return to bug 232581