]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/gssd/svcgssd_proc.c
Imported Debian patch 1.0.8-10
[nfs-utils.git] / utils / gssd / svcgssd_proc.c
index 14b7f17c61bd0ded02a0885f8c14230bebbadc22..3d67dc678b7f45fc8bdd63b328f28a7eddc3dafa 100644 (file)
@@ -200,7 +200,8 @@ get_ids(gss_name_t client_name, gss_OID mech, struct svc_cred *cred)
                        maj_stat, min_stat, mech);
                goto out;
        }
-       if (!(sname = calloc(name.length + 1, 1))) {
+       if (name.length >= 0xffff || /* be certain name.length+1 doesn't overflow */
+           !(sname = calloc(name.length + 1, 1))) {
                printerr(0, "WARNING: get_ids: error allocating %d bytes "
                        "for sname\n", name.length + 1);
                gss_release_buffer(&min_stat, &name);
@@ -221,6 +222,21 @@ get_ids(gss_name_t client_name, gss_OID mech, struct svc_cred *cred)
        if (res < 0) {
                printerr(0, "WARNING: get_ids: unable to map "
                        "name '%s' to a uid\n", sname);
+               /*
+                * -ENOENT means there was no mapping, any other error
+                * value means there was an error trying to do the
+                * mapping.
+                */
+               if (res == -ENOENT) {
+                       cred->cr_uid = -2;      /* XXX */
+                       cred->cr_gid = -2;      /* XXX */
+                       cred->cr_groups[0] = -2;/* XXX */
+                       cred->cr_ngroups = 1;
+                       res = 0;
+                       goto out_free;
+               }
+               printerr(0, "WARNING: get_ids: failed to map name '%s' "
+                       "to uid/gid: %s\n", sname, strerror(-res));
                goto out_free;
        }
        cred->cr_uid = uid;