Source: nn
Version: 6.7.3-14
Severity: normal
Tags: patch

Dear Maintainer,

>From 4acca3d0ca72bb50c0fedbff1a59d49872789958 Mon Sep 17 00:00:00 2001
>From: Bjarni Ingi Gislason <bjarn...@rhi.hi.is>
>Date: Mon, 8 Mar 2021 23:06:25 +0000
>Subject: [PATCH] nntp.c: Use strchr() instead of index(); add
> feature_test_macros

  Add a feature_test_macros for "fdopen(3)", "mkstemp(3)", and
"strchr(3)".

  Add the header file <string.h> for "strchr(3)".

  Add a prototype for "get_group_line()".

  Move the prototype for "server_port()" from the function
"find_server()" to the prototype section at top of the file.

  Use "strchr()" instead of "index()", see "man 3 index".

Signed-off-by: Bjarni Ingi Gislason <bjarn...@rhi.hi.is>
---
 nntp.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/nntp.c b/nntp.c
index 43093b8..54785e8 100644
--- a/nntp.c
+++ b/nntp.c
@@ -13,10 +13,23 @@
  * any mistakes are mine :-)  ++Kim
  */
 
+/* feature_test_macros(7) for "fdopen()" and "mkstemp()" */
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 200809L
+#endif
+
+/* feature_test_macros(7) for strchr(3) */
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdarg.h>
+#include <string.h>
 #include <sys/param.h>
 #include <ctype.h>
 #include "config.h"
@@ -80,6 +93,7 @@ static int      reconnect_server(int);
 static int      connect_server(void);
 static void     debug_msg(char *prefix, char *str);
 static void     find_server(void);
+int            get_group_line(const char *, char *, size_t);
 static int      get_server_line(char *string, int size);
 static int      get_server(char *string, int size);
 static int      get_socket(void);
@@ -88,6 +102,7 @@ static int      copy_text(register FILE * fp);
 static struct cache *search_cache(article_number art, group_header * gh);
 static struct cache *new_cache_slot(void);
 static void     clean_cache(void);
+void           server_port(char *);
 static void     set_domain(void);
 static void     nntp_doauth(void);
 
@@ -210,7 +225,7 @@ find_server(void)
     char           *cp, *name;
     char            buf[BUFSIZ];
     FILE           *fp;
-    void server_port(char *);
+
 
     /*
      * This feature cannot normally be enabled, because the database and the
@@ -896,7 +911,7 @@ set_domain(void)
     strncpy(domain, DOMAIN, MAXHOSTNAMELEN);
 #else
     strcpy(domain, host_name);
-    cp = index(domain, '.');
+    cp = strchr(domain, '.');
     if (cp == NULL) {
        strcat(domain, ".");
        strncat(domain, DOMAIN, MAXHOSTNAMELEN - sizeof(host_name) - 1);
@@ -907,7 +922,7 @@ set_domain(void)
 
     domain[0] = '\0';
 
-    cp = index(host_name, '.');
+    cp = strchr(host_name, '.');
     if (cp == NULL) {
        FILE           *resolv;
 
@@ -1683,8 +1698,8 @@ valid_header(register char *h)
      * just check for initial letter, colon, and space to make sure we
      * discard only invalid headers
      */
-    colon = index(h, ':');
-    space = index(h, ' ');
+    colon = strchr(h, ':');
+    space = strchr(h, ' ');
     if (isalpha(h[0]) && colon && space == colon + 1)
        return (1);
 
-- 
2.30.1



-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.9-1 (SMP w/2 CPU threads)
Locale: LANG=is_IS.iso88591, LC_CTYPE=is_IS.iso88591 (charmap=ISO-8859-1), 
LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

-- debconf information excluded

-- 
Bjarni I. Gislason

Reply via email to