]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/gssd/gssd_proc.c
gssd: NULL-terminate buffer after read in read_service_info (try #2)
[nfs-utils.git] / utils / gssd / gssd_proc.c
index 91fc8d23b8130c18346b1abecd4f646eff65e7ab..fb97a13e7e2761673d130397a2318db2fbf156e7 100644 (file)
 
 */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif /* HAVE_CONFIG_H */
+
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
-#include "config.h"
+
 #include <sys/param.h>
 #include <rpc/rpc.h>
 #include <sys/stat.h>
@@ -66,7 +70,6 @@
 #include "gssd.h"
 #include "err_util.h"
 #include "gss_util.h"
-#include "gss_oids.h"
 #include "krb5_util.h"
 #include "context.h"
 
@@ -104,7 +107,7 @@ static int
 read_service_info(char *info_file_name, char **servicename, char **servername,
                  int *prog, int *vers, char **protocol, int *port) {
 #define INFOBUFLEN 256
-       char            buf[INFOBUFLEN];
+       char            buf[INFOBUFLEN + 1];
        static char     dummy[128];
        int             nbytes;
        static char     service[128];
@@ -129,6 +132,7 @@ read_service_info(char *info_file_name, char **servicename, char **servername,
        if ((nbytes = read(fd, buf, INFOBUFLEN)) == -1)
                goto fail;
        close(fd);
+       buf[nbytes] = '\0';
 
        numfields = sscanf(buf,"RPC server: %127s\n"
                   "service: %127s %15s version %15s\n"
@@ -774,8 +778,10 @@ handle_krb5_upcall(struct clnt_info *clp)
 out:
        if (token.value)
                free(token.value);
+#ifndef HAVE_LIBTIRPC
        if (pd.pd_ctx_hndl.length != 0)
                authgss_free_private_data(&pd);
+#endif
        if (auth)
                AUTH_DESTROY(auth);
        if (rpc_clnt)