messages
listlengths 3
3
| metadata
dict |
|---|---|
[
{
"role": "system",
"content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."
},
{
"role": "user",
"content": "## CVE: CVE-2013-1418\n\nThe setup_server_realm function in main.c in the Key Distribution Center (KDC) in MIT Kerberos 5 (aka krb5) before 1.10.7, when multiple realms are configured, allows remote attackers to cause a denial of service (NULL pointer dereference and daemon crash) via a crafted request.\n\n## Package\nkrb5-mini\n\n## Files to modify\n- src/lib/krb5/os/changepw.c\n- krb5-1.10.2.orig/src/lib/krb5/os/changepw.c\n\n## Target Source Code\n\n### src/lib/krb5/os/changepw.c\n\n#### change_set_password() [lines 362-427]\n```c\n krb5_data *result_code_string,\n krb5_data *result_string)\n{\n return change_set_password(context, creds, newpw, NULL,\n result_code, result_code_string, result_string );\n}\n\n/*\n * krb5_set_password - Implements set password per RFC 3244\n *\n */\n\nkrb5_error_code KRB5_CALLCONV\nkrb5_set_password(krb5_context context,\n krb5_creds *creds,\n char *newpw,\n krb5_principal change_password_for,\n int *result_code,\n krb5_data *result_code_string,\n krb5_data *result_string\n)\n{\n return change_set_password(context, creds, newpw, change_password_for,\n result_code, result_code_string, result_string );\n}\n\nkrb5_error_code KRB5_CALLCONV\nkrb5_set_password_using_ccache(krb5_context context,\n krb5_ccache ccache,\n char *newpw,\n krb5_principal change_password_for,\n int *result_code,\n krb5_data *result_code_string,\n krb5_data *result_string\n)\n{\n krb5_creds creds;\n krb5_creds *credsp;\n krb5_error_code code;\n\n /*\n ** get the proper creds for use with krb5_set_password -\n */\n memset (&creds, 0, sizeof(creds));\n /*\n ** first get the principal for the password service -\n */\n code = krb5_cc_get_principal (context, ccache, &creds.client);\n if (!code) {\n code = krb5_build_principal(context, &creds.server,\n krb5_princ_realm(context, change_password_for)->length,\n krb5_princ_realm(context, change_password_for)->data,\n \"kadmin\", \"changepw\", NULL);\n if (!code) {\n code = krb5_get_credentials(context, 0, ccache, &creds, &credsp);\n if (!code) {\n code = krb5_set_password(context, credsp, newpw, change_password_for,\n result_code, result_code_string,\n result_string);\n krb5_free_creds(context, credsp);\n }\n }\n krb5_free_cred_contents(context, &creds);\n }\n return code;\n}\n```\n\n\n## Upstream Fix\n```diff\nFall back to TCP on kdc-unresolvable/unreachable errors. We still have\nto wait for UDP to fail, so this might not be ideal. RT #5868.\n\nIndex: krb5-1.10.2/src/lib/krb5/os/changepw.c\n===================================================================\n--- krb5-1.10.2.orig/src/lib/krb5/os/changepw.c\n+++ krb5-1.10.2/src/lib/krb5/os/changepw.c\n@@ -274,10 +274,22 @@ change_set_password(krb5_context context\n &callback_info, &chpw_rep, ss2sa(&remote_addr),\n &addrlen, NULL, NULL, NULL);\n if (code) {\n- /*\n- * Here we may want to switch to TCP on some errors.\n- * right?\n- */\n+ /* if we're not using a stream socket, and it's an error which\n+ * might reasonably be specific to a datagram \"connection\", try\n+ * again with a stream socket */\n+ if (!use_tcp) {\n+ switch (code) {\n+ case KRB5_KDC_UNREACH:\n+ case KRB5_REALM_CANT_RESOLVE:\n+ case KRB5KRB_ERR_RESPONSE_TOO_BIG:\n+ /* should we do this for more result codes than these? */\n+ k5_free_serverlist (&sl);\n+ use_tcp = 1;\n+ continue;\n+ default:\n+ break;\n+ }\n+ }\n break;\n }\n```\n\nGenerate a backported patch for the SUSE target version."
},
{
"role": "assistant",
"content": "Fall back to TCP on kdc-unresolvable/unreachable errors. We still have\nto wait for UDP to fail, so this might not be ideal. RT #5868.\n\nIndex: krb5-1.10.2/src/lib/krb5/os/changepw.c\n===================================================================\n--- krb5-1.10.2.orig/src/lib/krb5/os/changepw.c\n+++ krb5-1.10.2/src/lib/krb5/os/changepw.c\n@@ -274,10 +274,22 @@ change_set_password(krb5_context context\n &callback_info, &chpw_rep, ss2sa(&remote_addr),\n &addrlen, NULL, NULL, NULL);\n if (code) {\n- /*\n- * Here we may want to switch to TCP on some errors.\n- * right?\n- */\n+ /* if we're not using a stream socket, and it's an error which\n+ * might reasonably be specific to a datagram \"connection\", try\n+ * again with a stream socket */\n+ if (!use_tcp) {\n+ switch (code) {\n+ case KRB5_KDC_UNREACH:\n+ case KRB5_REALM_CANT_RESOLVE:\n+ case KRB5KRB_ERR_RESPONSE_TOO_BIG:\n+ /* should we do this for more result codes than these? */\n+ k5_free_serverlist (&sl);\n+ use_tcp = 1;\n+ continue;\n+ default:\n+ break;\n+ }\n+ }\n break;\n }"
}
] |
{
"id": "krb5-mini-2233-krb5-1.10-kpasswd_tcp.patch",
"cve_id": "CVE-2013-1418",
"package": "krb5-mini",
"tier": "identical",
"has_source_context": true,
"context_tokens_est": 615,
"context_files": 1,
"license": "MIT",
"upstream_enriched": null,
"upstream_commit": null,
"upstream_repo": null
}
|
[
{
"role": "system",
"content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."
},
{
"role": "user",
"content": "## CVE: CVE-2015-2698\n\nThe iakerb_gss_export_sec_context function in lib/gssapi/krb5/iakerb.c in MIT Kerberos 5 (aka krb5) 1.14 pre-release 2015-09-14 improperly accesses a certain pointer, which allows remote authenticated users to cause a denial of service (memory corruption) or possibly have unspecified other impact by interacting with an application that calls the gss_export_sec_context function. NOTE: this vulnerability exists because of an incorrect fix for CVE-2015-2696.\n\n## Package\nkrb5\n\n## Files to modify\n- src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c\n\n## Upstream Fix\n```diff\nFrom d1f707024f1d0af6e54a18885322d70fa15ec4d3 Mon Sep 17 00:00:00 2001\nFrom: Greg Hudson <ghudson@mit.edu>\nDate: Fri, 5 Dec 2014 14:01:39 -0500\nSubject: [PATCH] Fix LDAP misused policy name crash [CVE-2014-5353]\n\nIn krb5_ldap_get_password_policy_from_dn, if LDAP_SEARCH returns\nsuccessfully with no results, return KRB5_KDB_NOENTRY instead of\nreturning success with a zeroed-out policy object. This fixes a null\ndereference when an admin attempts to use an LDAP ticket policy name\nas a password policy name.\n\nCVE-2014-5353:\n\nIn MIT krb5, when kadmind is configured to use LDAP for the KDC\ndatabase, an authenticated remote attacker can cause a NULL dereference\nby attempting to use a named ticket policy object as a password policy\nfor a principal. The attacker needs to be authenticated as a user who\nhas the elevated privilege for setting password policy by adding or\nmodifying principals.\n\nQueries to LDAP scoped to the krbPwdPolicy object class will correctly\nnot return entries of other classes, such as ticket policy objects, but\nmay return success with no returned elements if an object with the\nrequested DN exists in a different object class. In this case, the\nroutine to retrieve a password policy returned success with a password\npolicy object that consisted entirely of zeroed memory. In particular,\naccesses to the policy name will dereference a NULL pointer. KDC\noperation does not access the policy name field, but most kadmin\noperations involving the principal with incorrect password policy\nwill trigger the crash.\n\nThanks to Patrik Kis for reporting this problem.\n\nCVSSv2 Vector: AV:N/AC:M/Au:S/C:N/I:N/A:C/E:H/RL:OF/RC:C\n\n[kaduk@mit.edu: CVE description and CVSS score]\n\nticket: 8051 (new)\ntarget_version: 1.13.1\ntags: pullup\n---\n src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c\nindex 522773e95b9..6779f51c7bf 100644\n--- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c\n+++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c\n@@ -314,10 +314,11 @@ krb5_ldap_get_password_policy_from_dn(krb5_context context, char *pol_name,\n LDAP_SEARCH(pol_dn, LDAP_SCOPE_BASE, \"(objectclass=krbPwdPolicy)\", password_policy_attributes);\n \n ent=ldap_first_entry(ld, result);\n- if (ent != NULL) {\n- if ((st = populate_policy(context, ld, ent, pol_name, *policy)) != 0)\n- goto cleanup;\n+ if (ent == NULL) {\n+ st = KRB5_KDB_NOENTRY;\n+ goto cleanup;\n }\n+ st = populate_policy(context, ld, ent, pol_name, *policy);\n \n cleanup:\n ldap_msgfree(result);\n```\n\nGenerate a backported patch for the SUSE target version."
},
{
"role": "assistant",
"content": "From d1f707024f1d0af6e54a18885322d70fa15ec4d3 Mon Sep 17 00:00:00 2001\nFrom: Greg Hudson <ghudson@mit.edu>\nDate: Fri, 5 Dec 2014 14:01:39 -0500\nSubject: [PATCH] Fix LDAP misused policy name crash [CVE-2014-5353]\n\nIn krb5_ldap_get_password_policy_from_dn, if LDAP_SEARCH returns\nsuccessfully with no results, return KRB5_KDB_NOENTRY instead of\nreturning success with a zeroed-out policy object. This fixes a null\ndereference when an admin attempts to use an LDAP ticket policy name\nas a password policy name.\n\nCVE-2014-5353:\n\nIn MIT krb5, when kadmind is configured to use LDAP for the KDC\ndatabase, an authenticated remote attacker can cause a NULL dereference\nby attempting to use a named ticket policy object as a password policy\nfor a principal. The attacker needs to be authenticated as a user who\nhas the elevated privilege for setting password policy by adding or\nmodifying principals.\n\nQueries to LDAP scoped to the krbPwdPolicy object class will correctly\nnot return entries of other classes, such as ticket policy objects, but\nmay return success with no returned elements if an object with the\nrequested DN exists in a different object class. In this case, the\nroutine to retrieve a password policy returned success with a password\npolicy object that consisted entirely of zeroed memory. In particular,\naccesses to the policy name will dereference a NULL pointer. KDC\noperation does not access the policy name field, but most kadmin\noperations involving the principal with incorrect password policy\nwill trigger the crash.\n\nThanks to Patrik Kis for reporting this problem.\n\nCVSSv2 Vector: AV:N/AC:M/Au:S/C:N/I:N/A:C/E:H/RL:OF/RC:C\n\n[kaduk@mit.edu: CVE description and CVSS score]\n\nticket: 8051 (new)\ntarget_version: 1.13.1\ntags: pullup\n---\n src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c\nindex 522773e..6779f51 100644\n--- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c\n+++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c\n@@ -314,10 +314,11 @@ krb5_ldap_get_password_policy_from_dn(krb5_context context, char *pol_name,\n LDAP_SEARCH(pol_dn, LDAP_SCOPE_BASE, \"(objectclass=krbPwdPolicy)\", password_policy_attributes);\n \n ent=ldap_first_entry(ld, result);\n- if (ent != NULL) {\n- if ((st = populate_policy(context, ld, ent, pol_name, *policy)) != 0)\n- goto cleanup;\n+ if (ent == NULL) {\n+ st = KRB5_KDB_NOENTRY;\n+ goto cleanup;\n }\n+ st = populate_policy(context, ld, ent, pol_name, *policy);\n \n cleanup:\n ldap_msgfree(result);"
}
] |
{
"id": "krb5-4431-krb5-1.12.2-CVE-2014-5353.patc",
"cve_id": "CVE-2015-2698",
"package": "krb5",
"tier": "adapted",
"has_source_context": false,
"context_tokens_est": null,
"context_files": null,
"license": "MIT",
"upstream_enriched": true,
"upstream_commit": "d1f707024f1d0af6e54a18885322d70fa15ec4d3",
"upstream_repo": "krb5/krb5"
}
|
[
{
"role": "system",
"content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."
},
{
"role": "user",
"content": "## CVE: CVE-2015-5276\n\nThe std::random_device class in libstdc++ in the GNU Compiler Collection (aka GCC) before 4.9.4 does not properly handle short reads from blocking sources, which makes it easier for context-dependent attackers to predict the random values via unspecified vectors.\n\n## Package\ngcc5\n\n## Files to modify\n- gcc/fortran/simplify.c\n- gcc/ubsan.c\n\n## Upstream Fix\n```diff\nIndex: configure.ac\n===================================================================\n--- configure.ac\t(revision 216911)\n+++ configure.ac\t(working copy)\n@@ -1454,7 +1454,7 @@ if test -d ${srcdir}/gcc && test \"x$have\n AC_MSG_CHECKING([for the correct version of mpfr.h])\n AC_TRY_COMPILE([#include <gmp.h>\n #include <mpfr.h>],[\n- #if MPFR_VERSION < MPFR_VERSION_NUM(2,4,0)\n+ #if MPFR_VERSION < MPFR_VERSION_NUM(2,3,1)\n choke me\n #endif\n ], [AC_TRY_COMPILE([#include <gmp.h>\nIndex: configure\n===================================================================\n--- configure\t(revision 216911)\n+++ configure\t(working copy)\n@@ -5524,7 +5524,7 @@ int\n main ()\n {\n \n- #if MPFR_VERSION < MPFR_VERSION_NUM(2,4,0)\n+ #if MPFR_VERSION < MPFR_VERSION_NUM(2,3,1)\n choke me\n #endif\n \nIndex: gcc/fortran/simplify.c\n===================================================================\n--- gcc/fortran/simplify.c\t(revision 216911)\n+++ gcc/fortran/simplify.c\t(working copy)\n@@ -4278,10 +4278,7 @@ gfc_simplify_mod (gfc_expr *a, gfc_expr\n \t return &gfc_bad_expr;\n \t }\n \n-\tgfc_set_model_kind (kind);\n-\tmpfr_fmod (result->value.real, a->value.real, p->value.real,\n-\t\t GFC_RND_MODE);\n-\tbreak;\n+\treturn NULL;\n \n default:\n \tgfc_internal_error (\"gfc_simplify_mod(): Bad arguments\");\n@@ -4327,19 +4324,7 @@ gfc_simplify_modulo (gfc_expr *a, gfc_ex\n \t return &gfc_bad_expr;\n \t }\n \n-\tgfc_set_model_kind (kind);\n-\tmpfr_fmod (result->value.real, a->value.real, p->value.real,\n-\t\t GFC_RND_MODE);\n-\tif (mpfr_cmp_ui (result->value.real, 0) != 0)\n-\t {\n-\t if (mpfr_signbit (a->value.real) != mpfr_signbit (p->value.real))\n-\t mpfr_add (result->value.real, result->value.real, p->value.real,\n-\t\t\tGFC_RND_MODE);\n-\t }\n-\telse\n-\t mpfr_copysign (result->value.real, result->value.real,\n-\t\t\t p->value.real, GFC_RND_MODE);\n-\tbreak;\n+\treturn NULL;\n \n default:\n \tgfc_internal_error (\"gfc_simplify_modulo(): Bad arguments\");\nIndex: gcc/ubsan.c\n===================================================================\n--- gcc/ubsan.c.orig\t2015-06-01 14:52:11.717105684 +0200\n+++ gcc/ubsan.c\t2015-06-01 14:52:26.945253071 +0200\n@@ -1564,40 +1564,6 @@\n \t min = build_real (expr_type, minval2);\n \t}\n }\n- else if (REAL_MODE_FORMAT (mode)->b == 10)\n- {\n- /* For _Decimal128 up to 34 decimal digits, - sign,\n-\t dot, e, exponent. */\n- char buf[64];\n- mpfr_t m;\n- int p = REAL_MODE_FORMAT (mode)->p;\n- REAL_VALUE_TYPE maxval, minval;\n-\n- /* Use mpfr_snprintf rounding to compute the smallest\n-\t representable decimal number greater or equal than\n-\t 1 << (prec - !uns_p). */\n- mpfr_init2 (m, prec + 2);\n- mpfr_set_ui_2exp (m, 1, prec - !uns_p, GMP_RNDN);\n- mpfr_snprintf (buf, sizeof buf, \"%.*RUe\", p - 1, m);\n- decimal_real_from_string (&maxval, buf);\n- max = build_real (expr_type, maxval);\n-\n- /* For unsigned, assume -1.0 is always representable. */\n- if (uns_p)\n-\tmin = build_minus_one_cst (expr_type);\n- else\n-\t{\n-\t /* Use mpfr_snprintf rounding to compute the largest\n-\t representable decimal number less or equal than\n-\t (-1 << (prec - 1)) - 1. */\n-\t mpfr_set_si_2exp (m, -1, prec - 1, GMP_RNDN);\n-\t mpfr_sub_ui (m, m, 1, GMP_RNDN);\n-\t mpfr_snprintf (buf, sizeof buf, \"%.*RDe\", p - 1, m);\n-\t decimal_real_from_string (&minval, buf);\n-\t min = build_real (expr_type, minval);\n-\t}\n- mpfr_clear (m);\n- }\n else\n return NULL_TREE;\n```\n\nGenerate a backported patch for the SUSE target version."
},
{
"role": "assistant",
"content": "Index: configure.ac\n===================================================================\n--- configure.ac\t(revision 216911)\n+++ configure.ac\t(working copy)\n@@ -1454,7 +1454,7 @@ if test -d ${srcdir}/gcc && test \"x$have\n AC_MSG_CHECKING([for the correct version of mpfr.h])\n AC_TRY_COMPILE([#include <gmp.h>\n #include <mpfr.h>],[\n- #if MPFR_VERSION < MPFR_VERSION_NUM(2,4,0)\n+ #if MPFR_VERSION < MPFR_VERSION_NUM(2,3,1)\n choke me\n #endif\n ], [AC_TRY_COMPILE([#include <gmp.h>\nIndex: configure\n===================================================================\n--- configure\t(revision 216911)\n+++ configure\t(working copy)\n@@ -5524,7 +5524,7 @@ int\n main ()\n {\n \n- #if MPFR_VERSION < MPFR_VERSION_NUM(2,4,0)\n+ #if MPFR_VERSION < MPFR_VERSION_NUM(2,3,1)\n choke me\n #endif\n \nIndex: gcc/fortran/simplify.c\n===================================================================\n--- gcc/fortran/simplify.c\t(revision 216911)\n+++ gcc/fortran/simplify.c\t(working copy)\n@@ -4278,10 +4278,7 @@ gfc_simplify_mod (gfc_expr *a, gfc_expr\n \t return &gfc_bad_expr;\n \t }\n \n-\tgfc_set_model_kind (kind);\n-\tmpfr_fmod (result->value.real, a->value.real, p->value.real,\n-\t\t GFC_RND_MODE);\n-\tbreak;\n+\treturn NULL;\n \n default:\n \tgfc_internal_error (\"gfc_simplify_mod(): Bad arguments\");\n@@ -4327,19 +4324,7 @@ gfc_simplify_modulo (gfc_expr *a, gfc_ex\n \t return &gfc_bad_expr;\n \t }\n \n-\tgfc_set_model_kind (kind);\n-\tmpfr_fmod (result->value.real, a->value.real, p->value.real,\n-\t\t GFC_RND_MODE);\n-\tif (mpfr_cmp_ui (result->value.real, 0) != 0)\n-\t {\n-\t if (mpfr_signbit (a->value.real) != mpfr_signbit (p->value.real))\n-\t mpfr_add (result->value.real, result->value.real, p->value.real,\n-\t\t\tGFC_RND_MODE);\n-\t }\n-\telse\n-\t mpfr_copysign (result->value.real, result->value.real,\n-\t\t\t p->value.real, GFC_RND_MODE);\n-\tbreak;\n+\treturn NULL;\n \n default:\n \tgfc_internal_error (\"gfc_simplify_modulo(): Bad arguments\");\nIndex: gcc/ubsan.c\n===================================================================\n--- gcc/ubsan.c.orig\t2015-06-01 14:52:11.717105684 +0200\n+++ gcc/ubsan.c\t2015-06-01 14:52:26.945253071 +0200\n@@ -1564,40 +1564,6 @@\n \t min = build_real (expr_type, minval2);\n \t}\n }\n- else if (REAL_MODE_FORMAT (mode)->b == 10)\n- {\n- /* For _Decimal128 up to 34 decimal digits, - sign,\n-\t dot, e, exponent. */\n- char buf[64];\n- mpfr_t m;\n- int p = REAL_MODE_FORMAT (mode)->p;\n- REAL_VALUE_TYPE maxval, minval;\n-\n- /* Use mpfr_snprintf rounding to compute the smallest\n-\t representable decimal number greater or equal than\n-\t 1 << (prec - !uns_p). */\n- mpfr_init2 (m, prec + 2);\n- mpfr_set_ui_2exp (m, 1, prec - !uns_p, GMP_RNDN);\n- mpfr_snprintf (buf, sizeof buf, \"%.*RUe\", p - 1, m);\n- decimal_real_from_string (&maxval, buf);\n- max = build_real (expr_type, maxval);\n-\n- /* For unsigned, assume -1.0 is always representable. */\n- if (uns_p)\n-\tmin = build_minus_one_cst (expr_type);\n- else\n-\t{\n-\t /* Use mpfr_snprintf rounding to compute the largest\n-\t representable decimal number less or equal than\n-\t (-1 << (prec - 1)) - 1. */\n-\t mpfr_set_si_2exp (m, -1, prec - 1, GMP_RNDN);\n-\t mpfr_sub_ui (m, m, 1, GMP_RNDN);\n-\t mpfr_snprintf (buf, sizeof buf, \"%.*RDe\", p - 1, m);\n-\t decimal_real_from_string (&minval, buf);\n-\t min = build_real (expr_type, minval);\n-\t}\n- mpfr_clear (m);\n- }\n else\n return NULL_TREE;"
}
] |
{
"id": "gcc5-4931-gcc48-remove-mpfr-2.4.0-requir",
"cve_id": "CVE-2015-5276",
"package": "gcc5",
"tier": "identical",
"has_source_context": false,
"context_tokens_est": null,
"context_files": null,
"license": "GPL-3.0-or-later",
"upstream_enriched": null,
"upstream_commit": null,
"upstream_repo": null
}
|
[
{
"role": "system",
"content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."
},
{
"role": "user",
"content": "## CVE: CVE-2014-9819\n\nHeap-based buffer overflow in ImageMagick allows remote attackers to have unspecified impact via a crafted palm file, a different vulnerability than CVE-2014-9823.\n\n## Package\nGraphicsMagick\n\n## Files to modify\n- coders/svg.c\n- GraphicsMagick-1.3.20.orig/coders/svg.c\n- magick/render.c\n- GraphicsMagick-1.3.20.orig/magick/render.c\n\n## Upstream Fix\n```diff\nIndex: GraphicsMagick-1.3.20/coders/svg.c\n===================================================================\n--- GraphicsMagick-1.3.20.orig/coders/svg.c\t2013-03-10 00:19:31.000000000 +0100\n+++ GraphicsMagick-1.3.20/coders/svg.c\t2016-06-23 10:05:21.805840780 +0200\n@@ -316,25 +316,22 @@ static char **GetTransformTokens(void *c\n *p,\n *q;\n \n- register long\n+ register size_t\n i;\n \n SVGInfo\n *svg_info;\n \n+ size_t\n+ alloc_tokens;\n+\n svg_info=(SVGInfo *) context;\n *number_tokens=0;\n if (text == (const char *) NULL)\n return((char **) NULL);\n- /*\n- Determine the number of arguments.\n- */\n- for (p=text; *p != '\\0'; p++)\n- {\n- if (*p == '(')\n- (*number_tokens)+=2;\n- }\n- tokens=MagickAllocateMemory(char **,(*number_tokens+2)*sizeof(*tokens));\n+\n+ alloc_tokens=8;\n+ tokens=MagickAllocateMemory(char **,(alloc_tokens+2)*sizeof(*tokens));\n if (tokens == (char **) NULL)\n {\n ThrowException3(svg_info->exception,ResourceLimitError,\n@@ -350,15 +347,28 @@ static char **GetTransformTokens(void *c\n {\n if ((*q != '(') && (*q != ')') && (*q != '\\0'))\n continue;\n+ if (i == alloc_tokens)\n+ {\n+ alloc_tokens <<= 1;\n+ MagickReallocMemory(char **,tokens,(alloc_tokens+2)*sizeof(*tokens));\n+ if (tokens == (char **) NULL)\n+ {\n+ ThrowException3(svg_info->exception,ResourceLimitError,\n+ MemoryAllocationFailed,UnableToConvertStringToTokens);\n+ return((char **) NULL);\n+ }\n+ }\n tokens[i]=AllocateString(p);\n (void) strlcpy(tokens[i],p,q-p+1);\n- Strip(tokens[i++]);\n+ Strip(tokens[i]);\n+ i++;\n p=q+1;\n }\n tokens[i]=AllocateString(p);\n (void) strlcpy(tokens[i],p,q-p+1);\n Strip(tokens[i++]);\n tokens[i]=(char *) NULL;\n+ *number_tokens=i;\n return(tokens);\n }\n \n@@ -1177,18 +1187,20 @@ static void SVGStartElement(void *contex\n IdentityAffine(&transform);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\" \");\n tokens=GetTransformTokens(context,value,&number_tokens);\n- for (j=0; j < (number_tokens-1); j+=2)\n+ if ((tokens != (char **) NULL) && (number_tokens > 0))\n {\n- keyword=(char *) tokens[j];\n- if (keyword == (char *) NULL)\n- continue;\n- value=(char *) tokens[j+1];\n- (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n- \" %.1024s: %.1024s\",keyword,value);\n- current=transform;\n- IdentityAffine(&affine);\n- switch (*keyword)\n+ for (j=0; j < (number_tokens-1); j+=2)\n {\n+ keyword=(char *) tokens[j];\n+ if (keyword == (char *) NULL)\n+ continue;\n+ value=(char *) tokens[j+1];\n+ (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n+ \" %.1024s: %.1024s\",keyword,value);\n+ current=transform;\n+ IdentityAffine(&affine);\n+ switch (*keyword)\n+ {\n case 'M':\n case 'm':\n {\n@@ -1293,22 +1305,23 @@ static void SVGStartElement(void *contex\n }\n default:\n break;\n- }\n- transform.sx=current.sx*affine.sx+current.ry*affine.rx;\n- transform.rx=current.rx*affine.sx+current.sy*affine.rx;\n- transform.ry=current.sx*affine.ry+current.ry*affine.sy;\n- transform.sy=current.rx*affine.ry+current.sy*affine.sy;\n- transform.tx=current.sx*affine.tx+current.ry*affine.ty+\n- current.tx;\n- transform.ty=current.rx*affine.tx+current.sy*affine.ty+\n- current.ty;\n- }\n- MVGPrintf(svg_info->file,\"affine %g %g %g %g %g %g\\n\",\n- transform.sx,transform.rx,transform.ry,transform.sy,\n- transform.tx,transform.ty);\n- for (j=0; tokens[j] != (char *) NULL; j++)\n- MagickFreeMemory(tokens[j]);\n- MagickFreeMemory(tokens);\n+ } /* end switch */\n+ transform.sx=current.sx*affine.sx+current.ry*affine.rx;\n+ transform.rx=current.rx*affine.sx+current.sy*affine.rx;\n+ transform.ry=current.sx*affine.ry+current.ry*affine.sy;\n+ transform.sy=current.rx*affine.ry+current.sy*affine.sy;\n+ transform.tx=current.sx*affine.tx+current.ry*affine.ty+\n+ current.tx;\n+ transform.ty=current.rx*affine.tx+current.sy*affine.ty+\n+ current.ty;\n+ } /* end for */\n+ MVGPrintf(svg_info->file,\"affine %g %g %g %g %g %g\\n\",\n+ transform.sx,transform.rx,transform.ry,transform.sy,\n+ transform.tx,transform.ty);\n+ for (j=0; tokens[j] != (char *) NULL; j++)\n+ MagickFreeMemory(tokens[j]);\n+ MagickFreeMemory(tokens);\n+ } /* end if */\n break;\n }\n if (LocaleCompare(keyword,\"gradientUnits\") == 0)\n@@ -1746,6 +1759,8 @@ static void SVGStartElement(void *contex\n IdentityAffine(&transform);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\" \");\n tokens=GetTransformTokens(context,value,&number_tokens);\n+ if ((tokens != (char **) NULL) && (number_tokens > 0))\n+ {\n for (j=0; j < (number_tokens-1); j+=2)\n {\n keyword=(char *) tokens[j];\n@@ -1873,8 +1888,10 @@ static void SVGStartElement(void *contex\n MVGPrintf(svg_info->file,\"affine %g %g %g %g %g %g\\n\",\n transform.sx,transform.rx,transform.ry,transform.sy,\n transform.tx,transform.ty);\n- for (j=0; tokens[j] != (char *) NULL; j++)\n- MagickFreeMemory(tokens[j]);\n+ }\n+ if (number_tokens > 0)\n+ for (j=0; tokens[j] != (char *) NULL; j++)\n+ MagickFreeMemory(tokens[j]);\n MagickFreeMemory(tokens);\n break;\n }\nIndex: GraphicsMagick-1.3.20/magick/render.c\n===================================================================\n--- GraphicsMagick-1.3.20.orig/magick/render.c\t2016-06-23 10:05:21.649838266 +0200\n+++ GraphicsMagick-1.3.20/magick/render.c\t2016-06-23 10:05:21.805840780 +0200\n@@ -432,7 +432,7 @@ ConvertPathToPolygon(const PathInfo *pat\n {\n number_edges<<=1;\n MagickReallocMemory(EdgeInfo *,polygon_info->edges,\n- number_edges*sizeof(EdgeInfo));\n+ MagickArraySize(number_edges,sizeof(EdgeInfo)));\n if (polygon_info->edges == (EdgeInfo *) NULL)\n return((PolygonInfo *) NULL);\n }\n@@ -484,7 +484,7 @@ ConvertPathToPolygon(const PathInfo *pat\n {\n number_edges<<=1;\n MagickReallocMemory(EdgeInfo *,polygon_info->edges,\n- number_edges*sizeof(EdgeInfo));\n+ MagickArraySize(number_edges,sizeof(EdgeInfo)));\n if (polygon_info->edges == (EdgeInfo *) NULL)\n return((PolygonInfo *) NULL);\n }\n@@ -517,7 +517,7 @@ ConvertPathToPolygon(const PathInfo *pat\n if (n == number_points)\n {\n number_points<<=1;\n- MagickReallocMemory(PointInfo *,points,number_points*sizeof(PointInfo));\n+ MagickReallocMemory(PointInfo *,points,MagickArraySize(number_points,sizeof(PointInfo)));\n if (points == (PointInfo *) NULL)\n return((PolygonInfo *) NULL);\n }\n@@ -541,7 +541,7 @@ ConvertPathToPolygon(const PathInfo *p\n... (truncated)\n```\n\nGenerate a backported patch for the SUSE target version."
},
{
"role": "assistant",
"content": "Index: GraphicsMagick-1.3.20/coders/svg.c\n===================================================================\n--- GraphicsMagick-1.3.20.orig/coders/svg.c\t2013-03-10 00:19:31.000000000 +0100\n+++ GraphicsMagick-1.3.20/coders/svg.c\t2016-06-23 10:05:21.805840780 +0200\n@@ -316,25 +316,22 @@ static char **GetTransformTokens(void *c\n *p,\n *q;\n \n- register long\n+ register size_t\n i;\n \n SVGInfo\n *svg_info;\n \n+ size_t\n+ alloc_tokens;\n+\n svg_info=(SVGInfo *) context;\n *number_tokens=0;\n if (text == (const char *) NULL)\n return((char **) NULL);\n- /*\n- Determine the number of arguments.\n- */\n- for (p=text; *p != '\\0'; p++)\n- {\n- if (*p == '(')\n- (*number_tokens)+=2;\n- }\n- tokens=MagickAllocateMemory(char **,(*number_tokens+2)*sizeof(*tokens));\n+\n+ alloc_tokens=8;\n+ tokens=MagickAllocateMemory(char **,(alloc_tokens+2)*sizeof(*tokens));\n if (tokens == (char **) NULL)\n {\n ThrowException3(svg_info->exception,ResourceLimitError,\n@@ -350,15 +347,28 @@ static char **GetTransformTokens(void *c\n {\n if ((*q != '(') && (*q != ')') && (*q != '\\0'))\n continue;\n+ if (i == alloc_tokens)\n+ {\n+ alloc_tokens <<= 1;\n+ MagickReallocMemory(char **,tokens,(alloc_tokens+2)*sizeof(*tokens));\n+ if (tokens == (char **) NULL)\n+ {\n+ ThrowException3(svg_info->exception,ResourceLimitError,\n+ MemoryAllocationFailed,UnableToConvertStringToTokens);\n+ return((char **) NULL);\n+ }\n+ }\n tokens[i]=AllocateString(p);\n (void) strlcpy(tokens[i],p,q-p+1);\n- Strip(tokens[i++]);\n+ Strip(tokens[i]);\n+ i++;\n p=q+1;\n }\n tokens[i]=AllocateString(p);\n (void) strlcpy(tokens[i],p,q-p+1);\n Strip(tokens[i++]);\n tokens[i]=(char *) NULL;\n+ *number_tokens=i;\n return(tokens);\n }\n \n@@ -1177,18 +1187,20 @@ static void SVGStartElement(void *contex\n IdentityAffine(&transform);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\" \");\n tokens=GetTransformTokens(context,value,&number_tokens);\n- for (j=0; j < (number_tokens-1); j+=2)\n+ if ((tokens != (char **) NULL) && (number_tokens > 0))\n {\n- keyword=(char *) tokens[j];\n- if (keyword == (char *) NULL)\n- continue;\n- value=(char *) tokens[j+1];\n- (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n- \" %.1024s: %.1024s\",keyword,value);\n- current=transform;\n- IdentityAffine(&affine);\n- switch (*keyword)\n+ for (j=0; j < (number_tokens-1); j+=2)\n {\n+ keyword=(char *) tokens[j];\n+ if (keyword == (char *) NULL)\n+ continue;\n+ value=(char *) tokens[j+1];\n+ (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n+ \" %.1024s: %.1024s\",keyword,value);\n+ current=transform;\n+ IdentityAffine(&affine);\n+ switch (*keyword)\n+ {\n case 'M':\n case 'm':\n {\n@@ -1293,22 +1305,23 @@ static void SVGStartElement(void *contex\n }\n default:\n break;\n- }\n- transform.sx=current.sx*affine.sx+current.ry*affine.rx;\n- transform.rx=current.rx*affine.sx+current.sy*affine.rx;\n- transform.ry=current.sx*affine.ry+current.ry*affine.sy;\n- transform.sy=current.rx*affine.ry+current.sy*affine.sy;\n- transform.tx=current.sx*affine.tx+current.ry*affine.ty+\n- current.tx;\n- transform.ty=current.rx*affine.tx+current.sy*affine.ty+\n- current.ty;\n- }\n- MVGPrintf(svg_info->file,\"affine %g %g %g %g %g %g\\n\",\n- transform.sx,transform.rx,transform.ry,transform.sy,\n- transform.tx,transform.ty);\n- for (j=0; tokens[j] != (char *) NULL; j++)\n- MagickFreeMemory(tokens[j]);\n- MagickFreeMemory(tokens);\n+ } /* end switch */\n+ transform.sx=current.sx*affine.sx+current.ry*affine.rx;\n+ transform.rx=current.rx*affine.sx+current.sy*affine.rx;\n+ transform.ry=current.sx*affine.ry+current.ry*affine.sy;\n+ transform.sy=current.rx*affine.ry+current.sy*affine.sy;\n+ transform.tx=current.sx*affine.tx+current.ry*affine.ty+\n+ current.tx;\n+ transform.ty=current.rx*affine.tx+current.sy*affine.ty+\n+ current.ty;\n+ } /* end for */\n+ MVGPrintf(svg_info->file,\"affine %g %g %g %g %g %g\\n\",\n+ transform.sx,transform.rx,transform.ry,transform.sy,\n+ transform.tx,transform.ty);\n+ for (j=0; tokens[j] != (char *) NULL; j++)\n+ MagickFreeMemory(tokens[j]);\n+ MagickFreeMemory(tokens);\n+ } /* end if */\n break;\n }\n if (LocaleCompare(keyword,\"gradientUnits\") == 0)\n@@ -1746,6 +1759,8 @@ static void SVGStartElement(void *contex\n IdentityAffine(&transform);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\" \");\n tokens=GetTransformTokens(context,value,&number_tokens);\n+ if ((tokens != (char **) NULL) && (number_tokens > 0))\n+ {\n for (j=0; j < (number_tokens-1); j+=2)\n {\n keyword=(char *) tokens[j];\n@@ -1873,8 +1888,10 @@ static void SVGStartElement(void *contex\n MVGPrintf(svg_info->file,\"affine %g %g %g %g %g %g\\n\",\n transform.sx,transform.rx,transform.ry,transform.sy,\n transform.tx,transform.ty);\n- for (j=0; tokens[j] != (char *) NULL; j++)\n- MagickFreeMemory(tokens[j]);\n+ }\n+ if (number_tokens > 0)\n+ for (j=0; tokens[j] != (char *) NULL; j++)\n+ MagickFreeMemory(tokens[j]);\n MagickFreeMemory(tokens);\n break;\n }\nIndex: GraphicsMagick-1.3.20/magick/render.c\n===================================================================\n--- GraphicsMagick-1.3.20.orig/magick/render.c\t2016-06-23 10:05:21.649838266 +0200\n+++ GraphicsMagick-1.3.20/magick/render.c\t2016-06-23 10:05:21.805840780 +0200\n@@ -432,7 +432,7 @@ ConvertPathToPolygon(const PathInfo *pat\n {\n number_edges<<=1;\n MagickReallocMemory(EdgeInfo *,polygon_info->edges,\n- number_edges*sizeof(EdgeInfo));\n+ MagickArraySize(number_edges,sizeof(EdgeInfo)));\n if (polygon_info->edges == (EdgeInfo *) NULL)\n return((PolygonInfo *) NULL);\n }\n@@ -484,7 +484,7 @@ ConvertPathToPolygon(const PathInfo *pat\n {\n number_edges<<=1;\n MagickReallocMemory(EdgeInfo *,polygon_info->edges,\n- number_edges*sizeof(EdgeInfo));\n+ MagickArraySize(number_edges,sizeof(EdgeInfo)));\n if (polygon_info->edges == (EdgeInfo *) NULL)\n return((PolygonInfo *) NULL);\n }\n@@ -517,7 +517,7 @@ ConvertPathToPolygon(const PathInfo *pat\n if (n == number_points)\n {\n number_points<<=1;\n- MagickReallocMemory(PointInfo *,points,number_points*sizeof(PointInfo));\n+ MagickReallocMemory(PointInfo *,points,MagickArraySize(number_points,sizeof(PointInfo)));\n if (points == (PointInfo *) NULL)\n return((PolygonInfo *) NULL);\n }\n@@ -541,7 +541,7 @@ ConvertPathToPolygon(const PathInfo *pat\n {\n number_edges<<=1;\n MagickReallocMemory(EdgeInfo *,polygon_info->edges,\n- number_edges*sizeof(EdgeInfo));\n+ MagickArraySize(number_edges,sizeof(EdgeInfo)));\n if (polygon_info->edges == (EdgeInfo *) NULL)\n return((PolygonInfo *) NULL);\n }\n@@ -2309,7 +2309,7 @@ DrawImage(Image *image,const DrawInfo *d\n {\n n++;\n MagickReallocMemory(DrawInfo **,graphic_context,\n- (n+1)*sizeof(DrawInfo *));\n+ MagickArraySize((n+1),sizeof(DrawInfo *)));\n if (graphic_context == (DrawInfo **) NULL)\n {\n ThrowException3(&image->exception,ResourceLimitError,\n@@ -2671,7 +2671,7 @@ DrawImage(Image *image,const DrawInfo *d\n continue;\n number_points<<=1;\n MagickReallocMemory(PrimitiveInfo *,primitive_info,\n- number_points*sizeof(PrimitiveInfo));\n+ MagickArraySize(number_points,sizeof(PrimitiveInfo)));\n if (primitive_info == (PrimitiveInfo *) NULL)\n {\n ThrowException3(&image->exception,ResourceLimitError,\n@@ -2777,7 +2777,7 @@ DrawImage(Image *image,const DrawInfo *d\n {\n number_points+=length+1;\n MagickReallocMemory(PrimitiveInfo *,primitive_info,\n- number_points*sizeof(PrimitiveInfo));\n+ MagickArraySize(number_points,sizeof(PrimitiveInfo)));\n if (primitive_info == (PrimitiveInfo *) NULL)\n {\n ThrowException3(&image->exception,ResourceLimitError,\n@@ -5468,8 +5468,8 @@ TraceStrokePolygon(const DrawInfo *draw_\n if (q >= (max_strokes-6*BezierQuantum-360))\n {\n max_strokes+=6*BezierQuantum+360;\n- MagickReallocMemory(PointInfo *,path_p,max_strokes*sizeof(PointInfo));\n- MagickReallocMemory(PointInfo *,path_q,max_strokes*sizeof(PointInfo));\n+ MagickReallocMemory(PointInfo *,path_p,MagickArraySize(max_strokes,sizeof(PointInfo)));\n+ MagickReallocMemory(PointInfo *,path_q,MagickArraySize(max_strokes,sizeof(PointInfo)));\n if ((path_p == (PointInfo *) NULL) || (path_q == (PointInfo *) NULL))\n {\n MagickFreeMemory(polygon_primitive);"
}
] |
{
"id": "GraphicsMagick-5467-GraphicsMagick-CVE-2016-2317.p",
"cve_id": "CVE-2014-9819",
"package": "GraphicsMagick",
"tier": "adapted",
"has_source_context": false,
"context_tokens_est": null,
"context_files": null,
"license": "MIT",
"upstream_enriched": null,
"upstream_commit": null,
"upstream_repo": null
}
|
[
{
"role": "system",
"content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."
},
{
"role": "user",
"content": "## CVE: CVE-2014-9761\n\nMultiple stack-based buffer overflows in the GNU C Library (aka glibc or libc6) before 2.23 allow context-dependent attackers to cause a denial of service (application crash) or possibly execute arbitrary code via a long argument to the (1) nan, (2) nanf, or (3) nanl function.\n\n## Package\nglibc-utils\n\n## Files to modify\n- glibc-2.19.orig/nss/nss_files/files-alias.c\n- glibc-2.19.orig/nis/nss_compat/compat-grp.c\n- glibc-2.19.orig/nis/nss_compat/compat-pwd.c\n- glibc-2.19.orig/nis/nss_compat/compat-spwd.c\n- nss/nss_files/files-XXX.c\n\n## Target Source Code\n\n### nis/nss_compat/compat-grp.c\n\n#### _nss_compat_setgrent() [lines 174-193]\n```c\n\n\nenum nss_status\n_nss_compat_setgrent (int stayopen)\n{\n enum nss_status result;\n\n __libc_lock_lock (lock);\n\n if (ni == NULL)\n init_nss_interface ();\n\n result = internal_setgrent (&ext_ent, stayopen, 1);\n\n __libc_lock_unlock (lock);\n\n return result;\n}\n\n\n```\n\n#### _nss_compat_endgrent() [lines 216-232]\n```c\n}\n\nenum nss_status\n_nss_compat_endgrent (void)\n{\n enum nss_status result;\n\n __libc_lock_lock (lock);\n\n result = internal_endgrent (&ext_ent);\n\n __libc_lock_unlock (lock);\n\n return result;\n}\n\n/* get the next group from NSS (+ entry) */\n```\n\n### nis/nss_compat/compat-pwd.c\n\n#### _nss_compat_setpwent() [lines 291-310]\n```c\n\n\nenum nss_status\n_nss_compat_setpwent (int stayopen)\n{\n enum nss_status result;\n\n __libc_lock_lock (lock);\n\n if (ni == NULL)\n init_nss_interface ();\n\n result = internal_setpwent (&ext_ent, stayopen, 1);\n\n __libc_lock_unlock (lock);\n\n return result;\n}\n\n\n```\n\n#### _nss_compat_endpwent() [lines 340-356]\n```c\n}\n\nenum nss_status\n_nss_compat_endpwent (void)\n{\n enum nss_status result;\n\n __libc_lock_lock (lock);\n\n result = internal_endpwent (&ext_ent);\n\n __libc_lock_unlock (lock);\n\n return result;\n}\n\n\n```\n\n### nis/nss_compat/compat-spwd.c\n\n#### copy_spwd_changes() [lines 134-171]\n```c\n}\n\nstatic void\ncopy_spwd_changes (struct spwd *dest, struct spwd *src,\n\t\t char *buffer, size_t buflen)\n{\n if (src->sp_pwdp != NULL && strlen (src->sp_pwdp))\n {\n if (buffer == NULL)\n\tdest->sp_pwdp = strdup (src->sp_pwdp);\n else if (dest->sp_pwdp &&\n\t strlen (dest->sp_pwdp) >= strlen (src->sp_pwdp))\n\tstrcpy (dest->sp_pwdp, src->sp_pwdp);\n else\n\t{\n\t dest->sp_pwdp = buffer;\n\t strcpy (dest->sp_pwdp, src->sp_pwdp);\n\t buffer += strlen (dest->sp_pwdp) + 1;\n\t buflen = buflen - (strlen (dest->sp_pwdp) + 1);\n\t}\n }\n if (src->sp_lstchg != 0)\n dest->sp_lstchg = src->sp_lstchg;\n if (src->sp_min != 0)\n dest->sp_min = src->sp_min;\n if (src->sp_max != 0)\n dest->sp_max = src->sp_max;\n if (src->sp_warn != -1)\n dest->sp_warn = src->sp_warn;\n if (src->sp_inact != -1)\n dest->sp_inact = src->sp_inact;\n if (src->sp_expire != -1)\n dest->sp_expire = src->sp_expire;\n if (src->sp_flag != ~0ul)\n dest->sp_flag = src->sp_flag;\n}\n\nstatic enum nss_status\n```\n\n#### internal_setspent() [lines 169-248]\n```c\n}\n\nstatic enum nss_status\ninternal_setspent (ent_t *ent, int stayopen)\n{\n enum nss_status status = NSS_STATUS_SUCCESS;\n\n ent->first = ent->netgroup = 0;\n ent->files = true;\n\n /* If something was left over free it. */\n if (ent->netgroup)\n __internal_endnetgrent (&ent->netgrdata);\n\n if (ent->blacklist.data != NULL)\n {\n ent->blacklist.current = 1;\n ent->blacklist.data[0] = '|';\n ent->blacklist.data[1] = '\\0';\n }\n else\n ent->blacklist.current = 0;\n\n if (ent->stream == NULL)\n {\n ent->stream = fopen (\"/etc/shadow\", \"rme\");\n\n if (ent->stream == NULL)\n\tstatus = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;\n else\n\t{\n\t /* We have to make sure the file is `closed on exec'. */\n\t int result = 0;\n\n\t if (__compat_have_cloexec <= 0)\n\t {\n\t int flags;\n\t result = flags = fcntl (fileno_unlocked (ent->stream), F_GETFD,\n\t\t\t\t 0);\n\t if (result >= 0)\n\t\t{\n#if defined O_CLOEXEC && !defined __ASSUME_O_CLOEXEC\n\t\t if (__compat_have_cloexec == 0)\n/* ... truncated ... */\n```\n\n### nss/nss_files/files-XXX.c\n\n#### region() [lines 21-125]\n```c\n#include <errno.h>\n#include <fcntl.h>\n#include <bits/libc-lock.h>\n#include \"nsswitch.h\"\n\n#include <kernel-features.h>\n\n/* These symbols are defined by the including source file:\n\n ENTNAME -- database name of the structure and functions (hostent, pwent).\n STRUCTURE -- struct name, define only if not ENTNAME (passwd, group).\n DATABASE -- string of the database file's name (\"hosts\", \"passwd\").\n\n NEED_H_ERRNO - defined iff an arg `int *herrnop' is used.\n\n Also see files-parse.c.\n*/\n\n#define ENTNAME_r\tCONCAT(ENTNAME,_r)\n\n#define DATAFILE\t\"/etc/\" DATABASE\n\n#ifdef NEED_H_ERRNO\n# include <netdb.h>\n# define H_ERRNO_PROTO\t, int *herrnop\n# define H_ERRNO_ARG\t, herrnop\n# define H_ERRNO_SET(val) (*herrnop = (val))\n#else\n# define H_ERRNO_PROTO\n# define H_ERRNO_ARG\n# define H_ERRNO_SET(val) ((void) 0)\n#endif\n\n#ifndef EXTRA_ARGS\n# define EXTRA_ARGS\n# define EXTRA_ARGS_DECL\n# define EXTRA_ARGS_VALUE\n#endif\n\n/* Locks the static variables in this file. */\n__libc_lock_define_initialized (static, lock)\n\f\n/* Maintenance of the shared stream open on the database file. */\n\nstatic FILE *stream;\nstatic fpos_t position;\nstatic enum { nouse, getent, getby } last_use;\nstatic int keep_stream;\n\n/* Open database file if not already opened. */\nstatic enum nss_status\ninternal_setent (int stayopen)\n{\n enum nss_status status = NSS_STATUS_SUCCESS;\n\n if (stream == NULL)\n {\n stream = fopen (DATAFILE, \"rce\");\n\n if (stream == NULL)\n\tstatus = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;\n else\n\t{\n#if !defined O_CLOEXEC || !defined __ASSUME_O_CLOEXEC\n# ifdef O_CLOEXEC\n\t if (__have_o_cloexec <= 0)\n# endif\n\t {\n\t /* We have to make sure the file is `closed on exec'. */\n\t int result;\n\t int flags;\n\n\t result = flags = fcntl (fileno (stream), F_GETFD, 0);\n\t if (result >= 0)\n\t\t{\n# ifdef O_CLOEXEC\n\t\t if (__have_o_cloexec == 0)\n\t\t __have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1;\n\t\t if (__have_o_cloexec < 0)\n# endif\n\t\t {\n\t\t flags |= FD_CLOEXEC;\n\t\t result = fcntl (fileno (stream), F_SETFD, flags);\n\t\t \n/* ... truncated ... */\n```\n\n### nss/nss_files/files-alias.c\n\n#### region() [lines 1-97]\n```c\n/* Mail alias file parser in nss_files module.\n Copyright (C) 1996-2014 Free Software Foundation, Inc.\n This file is part of the GNU C Library.\n Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.\n\n The GNU C Library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation; either\n version 2.1 of the License, or (at your option) any later version.\n\n The GNU C Library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with the GNU C Library; if not, see\n <http://www.gnu.org/licenses/>. */\n\n#include <aliases.h>\n#include <ctype.h>\n#include <errno.h>\n#include <fcntl.h>\n#include <bits/libc-lock.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n\n#include <kernel-features.h>\n\n#include \"nsswitch.h\"\n\n/* Locks the static variables in this file. */\n__libc_lock_define_initialized (static, lock)\n\f\n/* Maintenance of the shared stream open on the database file. */\n\nstatic FILE *stream;\nstatic fpos_t position;\nstatic enum { nouse, getent, getby } last_use;\n\n\nstatic enum nss_status\ninternal_setent (void)\n{\n enum nss_status status = NSS_STATUS_SUCCESS;\n\n if (stream == NULL)\n {\n stream = fopen (\"/etc/aliases\", \"rce\");\n\n if (stream == NULL)\n\tstatus = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;\n else\n\t{\n#if !defined O_CLOEXEC || !defined __ASSUME_O_CLOEXEC\n# ifdef O_CLOEXEC\n\t if (__have_o_cloexec <= 0)\n# endif\n\t {\n\t /* We have to make sure the file is `closed on exec'. */\n\t int result;\n\t int flags;\n\n\t result = flags = fcntl (fileno (stream), F_GETFD, 0);\n\t if (result >= 0)\n\t\t{\n# ifdef O_CLOEXEC\n\t\t if (__have_o_cloexec == 0)\n\t\t __have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1;\n\t\t if (__ha\n/* ... truncated ... */\n```\n\n### nss/nss_files/files-hosts.c\n\n#### _nss_files_gethostbyname3_r() [lines 116-356]\n```c\n#undef EXTRA_ARGS_VALUE\n\nenum nss_status\n_nss_files_gethostbyname3_r (const char *name, int af, struct hostent *result,\n\t\t\t char *buffer, size_t buflen, int *errnop,\n\t\t\t int *herrnop, int32_t *ttlp, char **canonp)\n{\n uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct hostent_data);\n buffer += pad;\n buflen = buflen > pad ? buflen - pad : 0;\n\n __libc_lock_lock (lock);\n\n /* Reset file pointer to beginning or open file. */\n enum nss_status status = internal_setent (keep_stream);\n\n if (status == NSS_STATUS_SUCCESS)\n {\n /* XXX Is using _res to determine whether we want to convert IPv4\n addresses to IPv6 addresses really the right thing to do? */\n int flags = ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0);\n\n /* Tell getent function that we have repositioned the file pointer. */\n last_use = getby;\n\n while ((status = internal_getent (result, buffer, buflen, errnop,\n\t\t\t\t\therrnop, af, flags))\n\t == NSS_STATUS_SUCCESS)\n\t{\n\t LOOKUP_NAME_CASE (h_name, h_aliases)\n\t}\n\n if (status == NSS_STATUS_SUCCESS\n\t && _res_hconf.flags & HCONF_FLAG_MULTI)\n\t{\n\t /* We have to get all host entries from the file. */\n\t size_t tmp_buflen = MIN (buflen, 4096);\n\t char tmp_buffer_stack[tmp_buflen]\n\t __attribute__ ((__aligned__ (__alignof__ (struct hostent_data))));\n\t char *tmp_buffer = tmp_buffer_stack;\n/* ... 187 lines omitted ... */\n\t else\n\t status = NSS_STATUS_SUCCESS;\n\tout:\n\t if (tmp_buffer_malloced)\n\t free (tmp_buffer);\n\t}\n\n if (! keep_stream)\n\tinternal_endent ();\n }\n\n if (canonp && status == NSS_STATUS_SUCCESS)\n *canonp = result->h_name;\n\n __libc_lock_unlock (lock);\n\n return status;\n}\n\nenum nss_status\n```\n\n#### _nss_files_gethostbyname4_r() [lines 374-496]\n```c\n}\n\nenum nss_status\n_nss_files_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,\n\t\t\t char *buffer, size_t buflen, int *errnop,\n\t\t\t int *herrnop, int32_t *ttlp)\n{\n __libc_lock_lock (lock);\n\n /* Reset file pointer to beginning or open file. */\n enum nss_status status = interna\n/* ... truncated ... */\n```\n\n\n## Upstream Fix\n```diff\n2015-05-11 Andreas Schwab <schwab@suse.de>\n\n\t[BZ #18007]\n\t* nis/nss_compat/compat-grp.c (internal_endgrent): Don't call\n\tnss_endgrent.\n\t(_nss_compat_endgrent): Call nss_endgrent.\n\t* nis/nss_compat/compat-pwd.c (internal_endpwent): Don't call\n\tnss_endpwent.\n\t(_nss_compat_endpwent): Call nss_endpwent.\n\t* nis/nss_compat/compat-spwd.c (internal_setspent): Add parameter\n\tneedent, call nss_setspent only if non-zero.\n\t(_nss_compat_setspent, _nss_compat_getspent_r): Pass non-zero.\n\t(internal_endspent): Don't call nss_endspent.\n\t(_nss_compat_endspent): Call nss_endspent.\n\t* nss/nss_files/files-XXX.c (position, last_use, keep_stream):\n\tRemove. All uses removed.\n\t(internal_setent): Remove parameter stayopen, add parameter\n\tstream. Use it instead of global variable.\n\t(CONCAT(_nss_files_set,ENTNAME)): Pass global stream.\n\t(internal_endent, internal_getent): Add parameter stream. Use it\n\tinstead of global variable.\n\t(CONCAT(_nss_files_end,ENTNAME))\n\t(CONCAT(_nss_files_get,ENTNAME_r)): Pass global stream.\n\t(_nss_files_get##name##_r): Pass local stream. Remove locking.\n\t* nss/nss_files/files-alias.c (position, last_use): Remove. All\n\tuses removed.\n\t(internal_setent, internal_endent): Add parameter stream. Use it\n\tinstead of global variable.\n\t(_nss_files_setaliasent, _nss_files_endaliasent): Pass global\n\tstream.\n\t(get_next_alias): Add parameter stream.\n\t(_nss_files_getaliasent_r): Pass global stream.\n\t(_nss_files_getaliasbyname_r): Pass local stream. Remove locking.\n\t* nss/nss_files/files-hosts.c (_nss_files_gethostbyname3_r)\n\t(_nss_files_gethostbyname4_r): Pass local stream to\n\tinternal_setent, internal_getent and internal_endent. Remove\n\tlocking.\n\nIndex: glibc-2.19/nis/nss_compat/compat-grp.c\n===================================================================\n--- glibc-2.19.orig/nis/nss_compat/compat-grp.c\n+++ glibc-2.19/nis/nss_compat/compat-grp.c\n@@ -194,9 +194,6 @@ _nss_compat_setgrent (int stayopen)\n static enum nss_status\n internal_endgrent (ent_t *ent)\n {\n- if (nss_endgrent)\n- nss_endgrent ();\n-\n if (ent->stream != NULL)\n {\n fclose (ent->stream);\n@@ -222,6 +219,9 @@ _nss_compat_endgrent (void)\n \n __libc_lock_lock (lock);\n \n+ if (nss_endgrent)\n+ nss_endgrent ();\n+\n result = internal_endgrent (&ext_ent);\n \n __libc_lock_unlock (lock);\nIndex: glibc-2.19/nis/nss_compat/compat-pwd.c\n===================================================================\n--- glibc-2.19.orig/nis/nss_compat/compat-pwd.c\n+++ glibc-2.19/nis/nss_compat/compat-pwd.c\n@@ -311,9 +311,6 @@ _nss_compat_setpwent (int stayopen)\n static enum nss_status\n internal_endpwent (ent_t *ent)\n {\n- if (nss_endpwent)\n- nss_endpwent ();\n-\n if (ent->stream != NULL)\n {\n fclose (ent->stream);\n@@ -346,6 +343,9 @@ _nss_compat_endpwent (void)\n \n __libc_lock_lock (lock);\n \n+ if (nss_endpwent)\n+ nss_endpwent ();\n+\n result = internal_endpwent (&ext_ent);\n \n __libc_lock_unlock (lock);\nIndex: glibc-2.19/nis/nss_compat/compat-spwd.c\n===================================================================\n--- glibc-2.19.orig/nis/nss_compat/compat-spwd.c\n+++ glibc-2.19/nis/nss_compat/compat-spwd.c\n@@ -169,7 +169,7 @@ copy_spwd_changes (struct spwd *dest, st\n }\n \n static enum nss_status\n-internal_setspent (ent_t *ent, int stayopen)\n+internal_setspent (ent_t *ent, int stayopen, int needent)\n {\n enum nss_status status = NSS_STATUS_SUCCESS;\n \n@@ -239,7 +239,7 @@ internal_setspent (ent_t *ent, int stayo\n \n give_spwd_free (&ent->pwd);\n \n- if (status == NSS_STATUS_SUCCESS && nss_setspent)\n+ if (needent && status == NSS_STATUS_SUCCESS && nss_setspent)\n ent->setent_status = nss_setspent (stayopen);\n \n return status;\n@@ -256,7 +256,7 @@ _nss_compat_setspent (int stayopen)\n if (ni == NULL)\n init_nss_interface ();\n \n- result = internal_setspent (&ext_ent, stayopen);\n+ result = internal_setspent (&ext_ent, stayopen, 1);\n \n __libc_lock_unlock (lock);\n \n@@ -267,9 +267,6 @@ _nss_compat_setspent (int stayopen)\n static enum nss_status\n internal_endspent (ent_t *ent)\n {\n- if (nss_endspent)\n- nss_endspent ();\n-\n if (ent->stream != NULL)\n {\n fclose (ent->stream);\n@@ -303,6 +300,9 @@ _nss_compat_endspent (void)\n \n __libc_lock_lock (lock);\n \n+ if (nss_endspent)\n+ nss_endspent ();\n+\n result = internal_endspent (&ext_ent);\n \n __libc_lock_unlock (lock);\n@@ -658,7 +658,7 @@ _nss_compat_getspent_r (struct spwd *pwd\n init_nss_interface ();\n \n if (ext_ent.stream == NULL)\n- result = internal_setspent (&ext_ent, 1);\n+ result = internal_setspent (&ext_ent, 1, 1);\n \n if (result == NSS_STATUS_SUCCESS)\n result = internal_getspent_r (pwd, &ext_ent, buffer, buflen, errnop);\n@@ -830,7 +830,7 @@ _nss_compat_getspnam_r (const char *name\n \n __libc_lock_unlock (lock);\n \n- result = internal_setspent (&ent, 0);\n+ result = internal_setspent (&ent, 0, 0);\n \n if (result == NSS_STATUS_SUCCESS)\n result = internal_getspnam_r (name, pwd, &ent, buffer, buflen, errnop);\nIndex: glibc-2.19/nss/nss_files/files-XXX.c\n===================================================================\n--- glibc-2.19.orig/nss/nss_files/files-XXX.c\n+++ glibc-2.19/nss/nss_files/files-XXX.c\n@@ -60,24 +60,23 @@\n /* Locks the static variables in this file. */\n __libc_lock_define_initialized (static, lock)\n \f\n-/* Maintenance of the shared stream open on the database file. */\n+/* Maintenance of the stream open on the database file. For getXXent\n+ operations the stream needs to be held open across calls, the other\n+ getXXbyYY operations all use their own stream. */\n \n static FILE *stream;\n-static fpos_t position;\n-static enum { nouse, getent, getby } last_use;\n-static int keep_stream;\n \n /* Open database file if not already opened. */\n static enum nss_status\n-internal_setent (int stayopen)\n+internal_setent (FILE **stream)\n {\n enum nss_status status = NSS_STATUS_SUCCESS;\n \n- if (stream == NULL)\n+ if (*stream == NULL)\n {\n- stream = fopen (DATAFILE, \"rce\");\n+ *stream = fopen (DATAFILE, \"rce\");\n \n- if (stream == NULL)\n+ if (*stream == NULL)\n \tstatus = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;\n else\n \t{\n@@ -90,7 +89,7 @@ internal_setent (int stayopen)\n \t int result;\n \t int flags;\n \n-\t result = flags = fcntl (fileno (stream), F_GETFD, 0);\n+\t result = flags = fcntl (fileno (*stream), F_GETFD, 0);\n \t if (result >= 0)\n \t\t{\n # ifdef O_CLOEXEC\n@@ -100,15 +99,15 @@ internal_setent (int stayopen)\n # endif\n \t\t {\n \t\t flags |= FD_CLOEXEC;\n-\t\t result = fcntl (fileno (stream), F_SETFD, flags);\n+\t\t result = fcntl (fileno (*stream), F_SETFD, flags);\n \t\t }\n \t\t}\n \t if (result < 0)\n \t\t{\n \t\t /* Something went wrong. Close the stream and return a\n \t\t failure. */\n-\t\t fclose (stream);\n-\t\t stream = NULL;\n+\t\t fclose (*stream);\n+\t\t *stream = NULL;\n \t\t status = NSS_STATUS_UNAVAIL;\n \t\t}\n \t }\n@@ -116,11 +115,7 @@ internal_setent (int stayopen)\n \t}\n }\n else\n- rewind (stream);\n-\n- /* Remember STAYOPEN flag. */\n- if (stream != NULL)\n- keep_stream |= stayopen;\n+ rewind (*stream);\n \n return status;\n }\n@@ -134,16 +129,7 @@ CONCAT(_nss_files_set,ENTNAME) (int stay\n \n __libc_lock_lock (lock);\n \n- status = internal_setent (stayopen);\n-\n- if (status == NSS_STATUS_SUCCESS && fgetpos (stream, &position) < 0)\n- {\n- fclose (stream);\n- stream = NULL;\n- status = NSS_STATUS_UNAVAIL;\n- }\n-\n- last_use = getent;\n+ status = internal_setent (&stream);\n \n __libc_lock_unlock (lock);\n \n@@ -153,12 +139,12 @@ CONCAT(_nss_files_set,ENTNAME) (int stay\n \n /* Close the database file. */\n static void\n-internal_endent (void)\n+internal_endent (FILE **stream)\n {\n- if (stream != NULL)\n+ if (*stream != NULL)\n {\n- fclose (stream);\n- stream = NULL;\n+ fclose (*stream);\n+ *stream = NULL;\n }\n }\n \n@@ -169,10 +155,7 @@ CONCAT(_nss_files_end,ENTNAME) (void)\n {\n __libc_lock_lock (lock);\n \n- internal_endent ();\n-\n- /* Reset STAYOPEN flag. */\n- ke\n... (truncated)\n```\n\nGenerate a backported patch for the SUSE target version."
},
{
"role": "assistant",
"content": "2015-05-11 Andreas Schwab <schwab@suse.de>\n\n\t[BZ #18007]\n\t* nis/nss_compat/compat-grp.c (internal_endgrent): Don't call\n\tnss_endgrent.\n\t(_nss_compat_endgrent): Call nss_endgrent.\n\t* nis/nss_compat/compat-pwd.c (internal_endpwent): Don't call\n\tnss_endpwent.\n\t(_nss_compat_endpwent): Call nss_endpwent.\n\t* nis/nss_compat/compat-spwd.c (internal_setspent): Add parameter\n\tneedent, call nss_setspent only if non-zero.\n\t(_nss_compat_setspent, _nss_compat_getspent_r): Pass non-zero.\n\t(internal_endspent): Don't call nss_endspent.\n\t(_nss_compat_endspent): Call nss_endspent.\n\t* nss/nss_files/files-XXX.c (position, last_use, keep_stream):\n\tRemove. All uses removed.\n\t(internal_setent): Remove parameter stayopen, add parameter\n\tstream. Use it instead of global variable.\n\t(CONCAT(_nss_files_set,ENTNAME)): Pass global stream.\n\t(internal_endent, internal_getent): Add parameter stream. Use it\n\tinstead of global variable.\n\t(CONCAT(_nss_files_end,ENTNAME))\n\t(CONCAT(_nss_files_get,ENTNAME_r)): Pass global stream.\n\t(_nss_files_get##name##_r): Pass local stream. Remove locking.\n\t* nss/nss_files/files-alias.c (position, last_use): Remove. All\n\tuses removed.\n\t(internal_setent, internal_endent): Add parameter stream. Use it\n\tinstead of global variable.\n\t(_nss_files_setaliasent, _nss_files_endaliasent): Pass global\n\tstream.\n\t(get_next_alias): Add parameter stream.\n\t(_nss_files_getaliasent_r): Pass global stream.\n\t(_nss_files_getaliasbyname_r): Pass local stream. Remove locking.\n\t* nss/nss_files/files-hosts.c (_nss_files_gethostbyname3_r)\n\t(_nss_files_gethostbyname4_r): Pass local stream to\n\tinternal_setent, internal_getent and internal_endent. Remove\n\tlocking.\n\nIndex: glibc-2.19/nis/nss_compat/compat-grp.c\n===================================================================\n--- glibc-2.19.orig/nis/nss_compat/compat-grp.c\n+++ glibc-2.19/nis/nss_compat/compat-grp.c\n@@ -194,9 +194,6 @@ _nss_compat_setgrent (int stayopen)\n static enum nss_status\n internal_endgrent (ent_t *ent)\n {\n- if (nss_endgrent)\n- nss_endgrent ();\n-\n if (ent->stream != NULL)\n {\n fclose (ent->stream);\n@@ -222,6 +219,9 @@ _nss_compat_endgrent (void)\n \n __libc_lock_lock (lock);\n \n+ if (nss_endgrent)\n+ nss_endgrent ();\n+\n result = internal_endgrent (&ext_ent);\n \n __libc_lock_unlock (lock);\nIndex: glibc-2.19/nis/nss_compat/compat-pwd.c\n===================================================================\n--- glibc-2.19.orig/nis/nss_compat/compat-pwd.c\n+++ glibc-2.19/nis/nss_compat/compat-pwd.c\n@@ -311,9 +311,6 @@ _nss_compat_setpwent (int stayopen)\n static enum nss_status\n internal_endpwent (ent_t *ent)\n {\n- if (nss_endpwent)\n- nss_endpwent ();\n-\n if (ent->stream != NULL)\n {\n fclose (ent->stream);\n@@ -346,6 +343,9 @@ _nss_compat_endpwent (void)\n \n __libc_lock_lock (lock);\n \n+ if (nss_endpwent)\n+ nss_endpwent ();\n+\n result = internal_endpwent (&ext_ent);\n \n __libc_lock_unlock (lock);\nIndex: glibc-2.19/nis/nss_compat/compat-spwd.c\n===================================================================\n--- glibc-2.19.orig/nis/nss_compat/compat-spwd.c\n+++ glibc-2.19/nis/nss_compat/compat-spwd.c\n@@ -169,7 +169,7 @@ copy_spwd_changes (struct spwd *dest, st\n }\n \n static enum nss_status\n-internal_setspent (ent_t *ent, int stayopen)\n+internal_setspent (ent_t *ent, int stayopen, int needent)\n {\n enum nss_status status = NSS_STATUS_SUCCESS;\n \n@@ -239,7 +239,7 @@ internal_setspent (ent_t *ent, int stayo\n \n give_spwd_free (&ent->pwd);\n \n- if (status == NSS_STATUS_SUCCESS && nss_setspent)\n+ if (needent && status == NSS_STATUS_SUCCESS && nss_setspent)\n ent->setent_status = nss_setspent (stayopen);\n \n return status;\n@@ -256,7 +256,7 @@ _nss_compat_setspent (int stayopen)\n if (ni == NULL)\n init_nss_interface ();\n \n- result = internal_setspent (&ext_ent, stayopen);\n+ result = internal_setspent (&ext_ent, stayopen, 1);\n \n __libc_lock_unlock (lock);\n \n@@ -267,9 +267,6 @@ _nss_compat_setspent (int stayopen)\n static enum nss_status\n internal_endspent (ent_t *ent)\n {\n- if (nss_endspent)\n- nss_endspent ();\n-\n if (ent->stream != NULL)\n {\n fclose (ent->stream);\n@@ -303,6 +300,9 @@ _nss_compat_endspent (void)\n \n __libc_lock_lock (lock);\n \n+ if (nss_endspent)\n+ nss_endspent ();\n+\n result = internal_endspent (&ext_ent);\n \n __libc_lock_unlock (lock);\n@@ -658,7 +658,7 @@ _nss_compat_getspent_r (struct spwd *pwd\n init_nss_interface ();\n \n if (ext_ent.stream == NULL)\n- result = internal_setspent (&ext_ent, 1);\n+ result = internal_setspent (&ext_ent, 1, 1);\n \n if (result == NSS_STATUS_SUCCESS)\n result = internal_getspent_r (pwd, &ext_ent, buffer, buflen, errnop);\n@@ -830,7 +830,7 @@ _nss_compat_getspnam_r (const char *name\n \n __libc_lock_unlock (lock);\n \n- result = internal_setspent (&ent, 0);\n+ result = internal_setspent (&ent, 0, 0);\n \n if (result == NSS_STATUS_SUCCESS)\n result = internal_getspnam_r (name, pwd, &ent, buffer, buflen, errnop);\nIndex: glibc-2.19/nss/nss_files/files-XXX.c\n===================================================================\n--- glibc-2.19.orig/nss/nss_files/files-XXX.c\n+++ glibc-2.19/nss/nss_files/files-XXX.c\n@@ -60,24 +60,23 @@\n /* Locks the static variables in this file. */\n __libc_lock_define_initialized (static, lock)\n \f\n-/* Maintenance of the shared stream open on the database file. */\n+/* Maintenance of the stream open on the database file. For getXXent\n+ operations the stream needs to be held open across calls, the other\n+ getXXbyYY operations all use their own stream. */\n \n static FILE *stream;\n-static fpos_t position;\n-static enum { nouse, getent, getby } last_use;\n-static int keep_stream;\n \n /* Open database file if not already opened. */\n static enum nss_status\n-internal_setent (int stayopen)\n+internal_setent (FILE **stream)\n {\n enum nss_status status = NSS_STATUS_SUCCESS;\n \n- if (stream == NULL)\n+ if (*stream == NULL)\n {\n- stream = fopen (DATAFILE, \"rce\");\n+ *stream = fopen (DATAFILE, \"rce\");\n \n- if (stream == NULL)\n+ if (*stream == NULL)\n \tstatus = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;\n else\n \t{\n@@ -90,7 +89,7 @@ internal_setent (int stayopen)\n \t int result;\n \t int flags;\n \n-\t result = flags = fcntl (fileno (stream), F_GETFD, 0);\n+\t result = flags = fcntl (fileno (*stream), F_GETFD, 0);\n \t if (result >= 0)\n \t\t{\n # ifdef O_CLOEXEC\n@@ -100,15 +99,15 @@ internal_setent (int stayopen)\n # endif\n \t\t {\n \t\t flags |= FD_CLOEXEC;\n-\t\t result = fcntl (fileno (stream), F_SETFD, flags);\n+\t\t result = fcntl (fileno (*stream), F_SETFD, flags);\n \t\t }\n \t\t}\n \t if (result < 0)\n \t\t{\n \t\t /* Something went wrong. Close the stream and return a\n \t\t failure. */\n-\t\t fclose (stream);\n-\t\t stream = NULL;\n+\t\t fclose (*stream);\n+\t\t *stream = NULL;\n \t\t status = NSS_STATUS_UNAVAIL;\n \t\t}\n \t }\n@@ -116,11 +115,7 @@ internal_setent (int stayopen)\n \t}\n }\n else\n- rewind (stream);\n-\n- /* Remember STAYOPEN flag. */\n- if (stream != NULL)\n- keep_stream |= stayopen;\n+ rewind (*stream);\n \n return status;\n }\n@@ -134,16 +129,7 @@ CONCAT(_nss_files_set,ENTNAME) (int stay\n \n __libc_lock_lock (lock);\n \n- status = internal_setent (stayopen);\n-\n- if (status == NSS_STATUS_SUCCESS && fgetpos (stream, &position) < 0)\n- {\n- fclose (stream);\n- stream = NULL;\n- status = NSS_STATUS_UNAVAIL;\n- }\n-\n- last_use = getent;\n+ status = internal_setent (&stream);\n \n __libc_lock_unlock (lock);\n \n@@ -153,12 +139,12 @@ CONCAT(_nss_files_set,ENTNAME) (int stay\n \n /* Close the database file. */\n static void\n-internal_endent (void)\n+internal_endent (FILE **stream)\n {\n- if (stream != NULL)\n+ if (*stream != NULL)\n {\n- fclose (stream);\n- stream = NULL;\n+ fclose (*stream);\n+ *stream = NULL;\n }\n }\n \n@@ -169,10 +155,7 @@ CONCAT(_nss_files_end,ENTNAME) (void)\n {\n __libc_lock_lock (lock);\n \n- internal_endent ();\n-\n- /* Reset STAYOPEN flag. */\n- keep_stream = 0;\n+ internal_endent (&stream);\n \n __libc_lock_unlock (lock);\n \n@@ -227,7 +210,7 @@ get_contents (char *linebuf, size_t len,\n \n /* Parsing the database file into `struct STRUCTURE' data structures. */\n static enum nss_status\n-internal_getent (struct STRUCTURE *result,\n+internal_getent (FILE *stream, struct STRUCTURE *result,\n \t\t char *buffer, size_t buflen, int *errnop H_ERRNO_PROTO\n \t\t EXTRA_ARGS_DECL)\n {\n@@ -300,45 +283,14 @@ CONCAT(_nss_files_get,ENTNAME_r) (struct\n {\n int save_errno = errno;\n \n- status = internal_setent (0);\n+ status = internal_setent (&stream);\n \n __set_errno (save_errno);\n-\n- if (status == NSS_STATUS_SUCCESS && fgetpos (stream, &position) < 0)\n-\t{\n-\t fclose (stream);\n-\t stream = NULL;\n-\t status = NSS_STATUS_UNAVAIL;\n-\t}\n }\n \n if (status == NSS_STATUS_SUCCESS)\n- {\n- /* If the last use was not by the getent function we need the\n-\t position the stream. */\n- if (last_use != getent)\n-\t{\n-\t if (fsetpos (stream, &position) < 0)\n-\t status = NSS_STATUS_UNAVAIL;\n-\t else\n-\t last_use = getent;\n-\t}\n-\n- if (status == NSS_STATUS_SUCCESS)\n-\t{\n-\t status = internal_getent (result, buffer, buflen, errnop\n-\t\t\t\t H_ERRNO_ARG EXTRA_ARGS_VALUE);\n-\n-\t /* Remember this position if we were successful. If the\n-\t operation failed we give the user a chance to repeat the\n-\t operation (perhaps the buffer was too small). */\n-\t if (status == NSS_STATUS_SUCCESS)\n-\t fgetpos (stream, &position);\n-\t else\n-\t /* We must make sure we reposition the stream the next call. */\n-\t last_use = nouse;\n-\t}\n- }\n+ status = internal_getent (stream, result, buffer, buflen, errnop\n+\t\t\t H_ERRNO_ARG EXTRA_ARGS_VALUE);\n \n __libc_lock_unlock (lock);\n \n@@ -364,27 +316,20 @@ _nss_files_get##name##_r (proto,\n \t\t\t size_t buflen, int *errnop H_ERRNO_PROTO)\t \\\n {\t\t\t\t\t\t\t\t\t \\\n enum nss_status status;\t\t\t\t\t\t \\\n+ FILE *stream = NULL;\t\t\t\t\t\t\t \\\n \t\t\t\t\t\t\t\t\t \\\n- __libc_lock_lock (lock);\t\t\t\t\t\t \\\n-\t\t\t\t\t\t\t\t\t \\\n- /* Reset file pointer to beginning or open file. */\t\t\t \\\n- status = internal_setent (keep_stream);\t\t\t\t \\\n+ /* Open file. */\t\t\t\t\t\t\t \\\n+ status = internal_setent (&stream);\t\t\t\t\t \\\n \t\t\t\t\t\t\t\t\t \\\n if (status == NSS_STATUS_SUCCESS)\t\t\t\t\t \\\n {\t\t\t\t\t\t\t\t\t \\\n- /* Tell getent function that we have repositioned the file pointer. */ \\\n- last_use = getby;\t\t\t\t\t\t\t \\\n-\t\t\t\t\t\t\t\t\t \\\n- while ((status = internal_getent (result, buffer, buflen, errnop\t \\\n+ while ((status = internal_getent (stream, result, buffer, buflen, errnop \\\n \t\t\t\t\tH_ERRNO_ARG EXTRA_ARGS_VALUE))\t \\\n \t == NSS_STATUS_SUCCESS)\t\t\t\t\t \\\n \t{ break_if_match }\t\t\t\t\t\t \\\n \t\t\t\t\t\t\t\t\t \\\n- if (! keep_stream)\t\t\t\t\t\t \\\n-\tinternal_endent ();\t\t\t\t\t\t \\\n+ internal_endent (&stream);\t\t\t\t\t \\\n }\t\t\t\t\t\t\t\t\t \\\n \t\t\t\t\t\t\t\t\t \\\n- __libc_lock_unlock (lock);\t\t\t\t\t\t \\\n-\t\t\t\t\t\t\t\t\t \\\n return status;\t\t\t\t\t\t\t \\\n }\nIndex: glibc-2.19/nss/nss_files/files-alias.c\n===================================================================\n--- glibc-2.19.orig/nss/nss_files/files-alias.c\n+++ glibc-2.19/nss/nss_files/files-alias.c\n@@ -33,23 +33,23 @@\n /* Locks the static variables in this file. */\n __libc_lock_define_initialized (static, lock)\n \f\n-/* Maintenance of the shared stream open on the database file. */\n+/* Maintenance of the stream open on the database file. For getXXent\n+ operations the stream needs to be held open across calls, the other\n+ getXXbyYY operations all use their own stream. */\n \n static FILE *stream;\n-static fpos_t position;\n-static enum { nouse, getent, getby } last_use;\n \n \n static enum nss_status\n-internal_setent (void)\n+internal_setent (FILE **stream)\n {\n enum nss_status status = NSS_STATUS_SUCCESS;\n \n- if (stream == NULL)\n+ if (*stream == NULL)\n {\n- stream = fopen (\"/etc/aliases\", \"rce\");\n+ *stream = fopen (\"/etc/aliases\", \"rce\");\n \n- if (stream == NULL)\n+ if (*stream == NULL)\n \tstatus = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;\n else\n \t{\n@@ -62,7 +62,7 @@ internal_setent (void)\n \t int result;\n \t int flags;\n \n-\t result = flags = fcntl (fileno (stream), F_GETFD, 0);\n+\t result = flags = fcntl (fileno (*stream), F_GETFD, 0);\n \t if (result >= 0)\n \t\t{\n # ifdef O_CLOEXEC\n@@ -72,14 +72,14 @@ internal_setent (void)\n # endif\n \t\t {\n \t\t flags |= FD_CLOEXEC;\n-\t\t result = fcntl (fileno (stream), F_SETFD, flags);\n+\t\t result = fcntl (fileno (*stream), F_SETFD, flags);\n \t\t }\n \t\t}\n \t if (result < 0)\n \t\t{\n \t\t /* Something went wrong. Close the stream and return a\n \t\t failure. */\n-\t\t fclose (stream);\n+\t\t fclose (*stream);\n \t\t stream = NULL;\n \t\t status = NSS_STATUS_UNAVAIL;\n \t\t}\n@@ -88,7 +88,7 @@ internal_setent (void)\n \t}\n }\n else\n- rewind (stream);\n+ rewind (*stream);\n \n return status;\n }\n@@ -102,16 +102,7 @@ _nss_files_setaliasent (void)\n \n __libc_lock_lock (lock);\n \n- status = internal_setent ();\n-\n- if (status == NSS_STATUS_SUCCESS && fgetpos (stream, &position) < 0)\n- {\n- fclose (stream);\n- stream = NULL;\n- status = NSS_STATUS_UNAVAIL;\n- }\n-\n- last_use = getent;\n+ status = internal_setent (&stream);\n \n __libc_lock_unlock (lock);\n \n@@ -121,12 +112,12 @@ _nss_files_setaliasent (void)\n \n /* Close the database file. */\n static void\n-internal_endent (void)\n+internal_endent (FILE **stream)\n {\n- if (stream != NULL)\n+ if (*stream != NULL)\n {\n- fclose (stream);\n- stream = NULL;\n+ fclose (*stream);\n+ *stream = NULL;\n }\n }\n \n@@ -137,7 +128,7 @@ _nss_files_endaliasent (void)\n {\n __libc_lock_lock (lock);\n \n- internal_endent ();\n+ internal_endent (&stream);\n \n __libc_lock_unlock (lock);\n \n@@ -146,7 +137,7 @@ _nss_files_endaliasent (void)\n \f\n /* Parsing the database file into `struct aliasent' data structures. */\n static enum nss_status\n-get_next_alias (const char *match, struct aliasent *result,\n+get_next_alias (FILE *stream, const char *match, struct aliasent *result,\n \t\tchar *buffer, size_t buflen, int *errnop)\n {\n enum nss_status status = NSS_STATUS_NOTFOUND;\n@@ -397,35 +388,16 @@ _nss_files_getaliasent_r (struct aliasen\n \n /* Be prepared that the set*ent function was not called before. */\n if (stream == NULL)\n- status = internal_setent ();\n+ status = internal_setent (&stream);\n \n if (status == NSS_STATUS_SUCCESS)\n {\n- /* If the last use was not by the getent function we need the\n-\t position the stream. */\n- if (last_use != getent)\n-\t{\n-\t if (fsetpos (stream, &position) < 0)\n-\t status = NSS_STATUS_UNAVAIL;\n-\t else\n-\t last_use = getent;\n-\t}\n-\n- if (status == NSS_STATUS_SUCCESS)\n-\t{\n-\t result->alias_local = 1;\n+ result->alias_local = 1;\n \n-\t /* Read lines until we get a definite result. */\n-\t do\n-\t status = get_next_alias (NULL, result, buffer, buflen, errnop);\n-\t while (status == NSS_STATUS_RETURN);\n-\n-\t /* If we successfully read an entry remember this position. */\n-\t if (status == NSS_STATUS_SUCCESS)\n-\t fgetpos (stream, &position);\n-\t else\n-\t last_use = nouse;\n-\t}\n+ /* Read lines until we get a definite result. */\n+ do\n+\tstatus = get_next_alias (stream, NULL, result, buffer, buflen, errnop);\n+ while (status == NSS_STATUS_RETURN);\n }\n \n __libc_lock_unlock (lock);\n@@ -440,6 +412,7 @@ _nss_files_getaliasbyname_r (const char\n {\n /* Return next entry in host file. */\n enum nss_status status = NSS_STATUS_SUCCESS;\n+ FILE *stream = NULL;\n \n if (name == NULL)\n {\n@@ -447,11 +420,8 @@ _nss_files_getaliasbyname_r (const char\n return NSS_STATUS_UNAVAIL;\n }\n \n- __libc_lock_lock (lock);\n-\n- /* Open the stream or rest it. */\n- status = internal_setent ();\n- last_use = getby;\n+ /* Open the stream. */\n+ status = internal_setent (&stream);\n \n if (status == NSS_STATUS_SUCCESS)\n {\n@@ -459,13 +429,11 @@ _nss_files_getaliasbyname_r (const char\n \n /* Read lines until we get a definite result. */\n do\n-\tstatus = get_next_alias (name, result, buffer, buflen, errnop);\n+\tstatus = get_next_alias (stream, name, result, buffer, buflen, errnop);\n while (status == NSS_STATUS_RETURN);\n }\n \n- internal_endent ();\n-\n- __libc_lock_unlock (lock);\n+ internal_endent (&stream);\n \n return status;\n }\nIndex: glibc-2.19/nss/nss_files/files-hosts.c\n===================================================================\n--- glibc-2.19.orig/nss/nss_files/files-hosts.c\n+++ glibc-2.19/nss/nss_files/files-hosts.c\n@@ -115,14 +115,13 @@ _nss_files_gethostbyname3_r (const char\n \t\t\t char *buffer, size_t buflen, int *errnop,\n \t\t\t int *herrnop, int32_t *ttlp, char **canonp)\n {\n+ FILE *stream = NULL;\n uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct hostent_data);\n buffer += pad;\n buflen = buflen > pad ? buflen - pad : 0;\n \n- __libc_lock_lock (lock);\n-\n- /* Reset file pointer to beginning or open file. */\n- enum nss_status status = internal_setent (keep_stream);\n+ /* Open file. */\n+ enum nss_status status = internal_setent (&stream);\n \n if (status == NSS_STATUS_SUCCESS)\n {\n@@ -130,10 +129,7 @@ _nss_files_gethostbyname3_r (const char\n addresses to IPv6 addresses really the right thing to do? */\n int flags = ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0);\n \n- /* Tell getent function that we have repositioned the file pointer. */\n- last_use = getby;\n-\n- while ((status = internal_getent (result, buffer, buflen, errnop,\n+ while ((status = internal_getent (stream, result, buffer, buflen, errnop,\n \t\t\t\t\therrnop, af, flags))\n \t == NSS_STATUS_SUCCESS)\n \t{\n@@ -160,7 +156,7 @@ _nss_files_gethostbyname3_r (const char\n \t bufferend = (char *) &result->h_aliases[naliases + 1];\n \n \tagain:\n-\t while ((status = internal_getent (&tmp_result_buf, tmp_buffer,\n+\t while ((status = internal_getent (stream, &tmp_result_buf, tmp_buffer,\n \t\t\t\t\t tmp_buflen, errnop, herrnop, af,\n \t\t\t\t\t flags))\n \t\t == NSS_STATUS_SUCCESS)\n@@ -336,15 +332,12 @@ _nss_files_gethostbyname3_r (const char\n \t free (tmp_buffer);\n \t}\n \n- if (! keep_stream)\n-\tinternal_endent ();\n+ internal_endent (&stream);\n }\n \n if (canonp && status == NSS_STATUS_SUCCESS)\n *canonp = result->h_name;\n \n- __libc_lock_unlock (lock);\n-\n return status;\n }\n \n@@ -373,16 +366,13 @@ _nss_files_gethostbyname4_r (const char\n \t\t\t char *buffer, size_t buflen, int *errnop,\n \t\t\t int *herrnop, int32_t *ttlp)\n {\n- __libc_lock_lock (lock);\n+ FILE *stream = NULL;\n \n- /* Reset file pointer to beginning or open file. */\n- enum nss_status status = internal_setent (keep_stream);\n+ /* Open file. */\n+ enum nss_status status = internal_setent (&stream);\n \n if (status == NSS_STATUS_SUCCESS)\n {\n- /* Tell getent function that we have repositioned the file pointer. */\n- last_use = getby;\n-\n bool any = false;\n bool got_canon = false;\n while (1)\n@@ -394,7 +384,7 @@ _nss_files_gethostbyname4_r (const char\n \t buflen = buflen > pad ? buflen - pad : 0;\n \n \t struct hostent result;\n-\t status = internal_getent (&result, buffer, buflen, errnop,\n+\t status = internal_getent (stream, &result, buffer, buflen, errnop,\n \t\t\t\t herrnop, AF_UNSPEC, 0);\n \t if (status != NSS_STATUS_SUCCESS)\n \t break;\n@@ -470,8 +460,7 @@ _nss_files_gethostbyname4_r (const char\n \t status = NSS_STATUS_SUCCESS;\n \t}\n \n- if (! keep_stream)\n-\tinternal_endent ();\n+ internal_endent (&stream);\n }\n else if (status == NSS_STATUS_TRYAGAIN)\n {\n@@ -484,7 +473,5 @@ _nss_files_gethostbyname4_r (const char\n *herrnop = NO_DATA;\n }\n \n- __libc_lock_unlock (lock);\n-\n return status;\n }"
}
] |
{
"id": "glibc-utils-4690-nss-separate-state-getXXent.pa",
"cve_id": "CVE-2014-9761",
"package": "glibc-utils",
"tier": "adapted",
"has_source_context": true,
"context_tokens_est": 2493,
"context_files": 6,
"license": "LGPL-2.1-or-later",
"upstream_enriched": null,
"upstream_commit": null,
"upstream_repo": null
}
|
[
{
"role": "system",
"content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."
},
{
"role": "user",
"content": "## CVE: CVE-2024-34459\n\nAn issue was discovered in xmllint (from libxml2) before 2.11.8 and 2.12.x before 2.12.7. Formatting error messages with xmllint --htmlout can result in a buffer over-read in xmlHTMLPrintFileContext in xmllint.c.\n\nSeverity: HIGH\nCVSS Score: 7.5\n\n## Package\nlibxml2\n\n## Files to modify\n- xmllint.c\n\n## Target Source Code\n\n### xmllint.c\n\n#### xmlHTMLPrintFileContext() [lines 584-628]\n```c\n */\n\nstatic void\nxmlHTMLPrintFileContext(xmlParserInputPtr input) {\n const xmlChar *cur, *base;\n int len;\n int n;\n\n if (input == NULL) return;\n xmlGenericError(xmlGenericErrorContext, \"<pre>\\n\");\n cur = input->cur;\n base = input->base;\n while ((cur > base) && ((*cur == '\\n') || (*cur == '\\r'))) {\n\tcur--;\n }\n n = 0;\n while ((n++ < 80) && (cur > base) && (*cur != '\\n') && (*cur != '\\r'))\n cur--;\n if ((*cur == '\\n') || (*cur == '\\r')) cur++;\n base = cur;\n n = 0;\n while ((*cur != 0) && (*cur != '\\n') && (*cur != '\\r') && (n < 79)) {\n\tlen = strlen(buffer);\n snprintf(&buffer[len], sizeof(buffer) - len, \"%c\",\n\t\t (unsigned char) *cur++);\n\tn++;\n }\n len = strlen(buffer);\n snprintf(&buffer[len], sizeof(buffer) - len, \"\\n\");\n cur = input->cur;\n while ((*cur == '\\n') || (*cur == '\\r'))\n\tcur--;\n n = 0;\n while ((cur != base) && (n++ < 80)) {\n\tlen = strlen(buffer);\n snprintf(&buffer[len], sizeof(buffer) - len, \" \");\n base++;\n }\n len = strlen(buffer);\n snprintf(&buffer[len], sizeof(buffer) - len, \"^\\n\");\n xmlHTMLEncodeSend();\n xmlGenericError(xmlGenericErrorContext, \"</pre>\");\n}\n\n/**\n```\n\n\n## Upstream Fix\n```diff\nFrom 3ad7f81624572ebd5b9e6058c9f67d38207c10e2 Mon Sep 17 00:00:00 2001\nFrom: Nick Wellnhofer <wellnhofer@aevum.de>\nDate: Wed, 8 May 2024 11:49:31 +0200\nSubject: [PATCH] [CVE-2024-34459] Fix buffer overread with `xmllint --htmlout`\n\nAdd a missing bounds check.\n\nFixes #720.\n---\n xmllint.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/xmllint.c b/xmllint.c\nindex b2afbe9697..35c328578d 100644\n--- a/xmllint.c\n+++ b/xmllint.c\n@@ -543,7 +543,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) {\n len = strlen(buffer);\n snprintf(&buffer[len], sizeof(buffer) - len, \"\\n\");\n cur = input->cur;\n- while ((*cur == '\\n') || (*cur == '\\r'))\n+ while ((cur > base) && ((*cur == '\\n') || (*cur == '\\r')))\n \tcur--;\n n = 0;\n while ((cur != base) && (n++ < 80)) {\n```\n\nGenerate a backported patch for the SUSE target version."
},
{
"role": "assistant",
"content": "From 3ad7f81624572ebd5b9e6058c9f67d38207c10e2 Mon Sep 17 00:00:00 2001\nFrom: Nick Wellnhofer <wellnhofer@aevum.de>\nDate: Wed, 8 May 2024 11:49:31 +0200\nSubject: [PATCH] [CVE-2024-34459] Fix buffer overread with `xmllint --htmlout`\n\nAdd a missing bounds check.\n\nFixes #720.\n---\n xmllint.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/xmllint.c b/xmllint.c\nindex b2afbe969..35c328578 100644\n--- a/xmllint.c\n+++ b/xmllint.c\n@@ -543,7 +543,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) {\n len = strlen(buffer);\n snprintf(&buffer[len], sizeof(buffer) - len, \"\\n\");\n cur = input->cur;\n- while ((*cur == '\\n') || (*cur == '\\r'))\n+ while ((cur > base) && ((*cur == '\\n') || (*cur == '\\r')))\n \tcur--;\n n = 0;\n while ((cur != base) && (n++ < 80)) {\n-- \nGitLab"
}
] |
{
"id": "libxml2-CVE-2024-34459-libxml2-CVE-2024-344",
"cve_id": "CVE-2024-34459",
"package": "libxml2",
"tier": "adapted",
"has_source_context": true,
"context_tokens_est": 316,
"context_files": 1,
"license": "MIT",
"upstream_enriched": true,
"upstream_commit": "3ad7f81624572ebd5b9e6058c9f67d38207c10e2",
"upstream_repo": "GNOME/libxml2"
}
|
[
{
"role": "system",
"content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."
},
{
"role": "user",
"content": "## CVE: CVE-2016-3706\n\nStack-based buffer overflow in the getaddrinfo function in sysdeps/posix/getaddrinfo.c in the GNU C Library (aka glibc or libc6) allows remote attackers to cause a denial of service (crash) via vectors involving hostent conversion. NOTE: this vulnerability exists because of an incomplete fix for CVE-2013-4458.\n\n## Package\nglibc-testsuite\n\n## Files to modify\n- glibc-2.19.orig/nss/nss_files/files-alias.c\n- glibc-2.19.orig/nis/nss_compat/compat-grp.c\n- glibc-2.19.orig/nis/nss_compat/compat-pwd.c\n- glibc-2.19.orig/nis/nss_compat/compat-spwd.c\n- nss/nss_files/files-XXX.c\n\n## Target Source Code\n\n### nis/nss_compat/compat-grp.c\n\n#### _nss_compat_setgrent() [lines 174-193]\n```c\n\n\nenum nss_status\n_nss_compat_setgrent (int stayopen)\n{\n enum nss_status result;\n\n __libc_lock_lock (lock);\n\n if (ni == NULL)\n init_nss_interface ();\n\n result = internal_setgrent (&ext_ent, stayopen, 1);\n\n __libc_lock_unlock (lock);\n\n return result;\n}\n\n\n```\n\n#### _nss_compat_endgrent() [lines 216-232]\n```c\n}\n\nenum nss_status\n_nss_compat_endgrent (void)\n{\n enum nss_status result;\n\n __libc_lock_lock (lock);\n\n result = internal_endgrent (&ext_ent);\n\n __libc_lock_unlock (lock);\n\n return result;\n}\n\n/* get the next group from NSS (+ entry) */\n```\n\n#### _nss_compat_getgrnam_r() [lines 511-540]\n```c\n}\n\nenum nss_status\n_nss_compat_getgrnam_r (const char *name, struct group *grp,\n\t\t\tchar *buffer, size_t buflen, int *errnop)\n{\n ent_t ent = { TRUE, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 }};\n enum nss_status result;\n\n if (name[0] == '-' || name[0] == '+')\n return NSS_STATUS_NOTFOUND;\n\n __libc_lock_lock (lock);\n\n if (ni == NULL)\n init_nss_interface ();\n\n __libc_lock_unlock (lock);\n\n result = internal_setgrent (&ent, 0, 0);\n\n if (result == NSS_STATUS_SUCCESS)\n result = internal_getgrnam_r (name, grp, &ent, buffer, buflen, errnop);\n\n internal_endgrent (&ent);\n\n return result;\n}\n\n/* Searches in /etc/group and the NIS/NIS+ map for a special group id */\n```\n\n#### _nss_compat_getgrgid_r() [lines 643-669]\n```c\n}\n\nenum nss_status\n_nss_compat_getgrgid_r (gid_t gid, struct group *grp,\n\t\t\tchar *buffer, size_t buflen, int *errnop)\n{\n ent_t ent = { TRUE, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 }};\n enum nss_status result;\n\n __libc_lock_lock (lock);\n\n if (ni == NULL)\n init_nss_interface ();\n\n __libc_lock_unlock (lock);\n\n result = internal_setgrent (&ent, 0, 0);\n\n if (result == NSS_STATUS_SUCCESS)\n result = internal_getgrgid_r (gid, grp, &ent, buffer, buflen, errnop);\n\n internal_endgrent (&ent);\n\n return result;\n}\n\n\n```\n\n### nis/nss_compat/compat-pwd.c\n\n#### _nss_compat_setpwent() [lines 291-310]\n```c\n\n\nenum nss_status\n_nss_compat_setpwent (int stayopen)\n{\n enum nss_status result;\n\n __libc_lock_lock (lock);\n\n if (ni == NULL)\n init_nss_interface ();\n\n result = internal_setpwent (&ext_ent, stayopen, 1);\n\n __libc_lock_unlock (lock);\n\n return result;\n}\n\n\n```\n\n#### _nss_compat_endpwent() [lines 340-356]\n```c\n}\n\nenum nss_status\n_nss_compat_endpwent (void)\n{\n enum nss_status result;\n\n __libc_lock_lock (lock);\n\n result = internal_endpwent (&ext_ent);\n\n __libc_lock_unlock (lock);\n\n return result;\n}\n\n\n```\n\n#### _nss_compat_getpwnam_r() [lines 849-879]\n```c\n}\n\nenum nss_status\n_nss_compat_getpwnam_r (const char *name, struct passwd *pwd,\n\t\t\tchar *buffer, size_t buflen, int *errnop)\n{\n enum nss_status result;\n ent_t ent = { false, false, true, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 },\n\t\t{ NULL, NULL, 0, 0, NULL, NULL, NULL }};\n\n if (name[0] == '-' || name[0] == '+')\n return NSS_STATUS_NOTFOUND;\n\n __libc_lock_lock (lock);\n\n if (ni == NULL)\n init_nss_interface ();\n\n __libc_lock_unlock (lock);\n\n result = internal_setpwent (&ent, 0, 0);\n\n if (result == NSS_STATUS_SUCCESS)\n result = internal_getpwnam_r (name, pwd, &ent, buffer, buflen, errnop);\n\n internal_endpwent (&ent);\n\n return result;\n}\n\n/* This function handle the + entry in /etc/passwd for getpwuid */\n```\n\n#### _nss_compat_getpwuid_r() [lines 1091-1118]\n```c\n}\n\nenum nss_status\n_nss_compat_getpwuid_r (uid_t uid, struct passwd *pwd,\n\t\t\tchar *buffer, size_t buflen, int *errnop)\n{\n enum nss_status result;\n ent_t ent = { false, false, true, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 },\n\t\t{ NULL, NULL, 0, 0, NULL, NULL, NULL }};\n\n __libc_lock_lock (lock);\n\n if (ni == NULL)\n init_nss_interface ();\n\n __libc_lock_unlock (lock);\n\n result = internal_setpwent (&ent, 0, 0);\n\n if (result == NSS_STATUS_SUCCESS)\n result = internal_getpwuid_r (uid, pwd, &ent, buffer, buflen, errnop);\n\n internal_endpwent (&ent);\n\n return result;\n}\n\n\n```\n\n### nis/nss_compat/compat-spwd.c\n\n#### copy_spwd_changes() [lines 134-171]\n```c\n}\n\nstatic void\ncopy_spwd_changes (struct spwd *dest, struct spwd *src,\n\t\t char *buffer, size_t buflen)\n{\n if (src->sp_pwdp != NULL && strlen (src->sp_pwdp))\n {\n if (buffer == NULL)\n\tdest->sp_pwdp = strdup (src->sp_pwdp);\n else if (dest->sp_pwdp &&\n\t strlen (dest->sp_pwdp) >= strlen (src->sp_pwdp))\n\tstrcpy (dest->sp_pwdp, src->sp_pwdp);\n else\n\t{\n\t dest->sp_pwdp = buffer;\n\t strcpy (dest->sp_pwdp, src->sp_pwdp);\n\t buffer += strlen (dest->sp_pwdp) + 1;\n\t buflen = buflen - (strlen (dest->sp_pwdp) + 1);\n\t}\n }\n if (src->sp_lstchg != 0)\n dest->sp_lstchg = src->sp_lstchg;\n if (src->sp_min != 0)\n dest->sp_min = src->sp_min;\n if (src->sp_max != 0)\n dest->sp_max = src->sp_max;\n if (src->sp_warn != -1)\n dest->sp_warn = src->sp_warn;\n if (src->sp_inact != -1)\n dest->sp_inact = src->sp_inact;\n if (src->sp_expire != -1)\n dest->sp_expire = src->sp_expire;\n if (src->sp_flag != ~0ul)\n dest->sp_flag = src->sp_flag;\n}\n\nstatic enum nss_status\n```\n\n#### internal_setspent() [lines 169-248]\n```c\n}\n\nstatic enum nss_status\ninternal_setspent (ent_t *ent, int stayopen)\n{\n enum nss_status status = NSS_STATUS_SUCCESS;\n\n ent->first = ent->netgroup = 0;\n ent->files = true;\n\n /* If something was left over free it. */\n if (ent->netgroup)\n __internal_endnetgrent (&ent->netgrdata);\n\n if (ent->blacklist.data != NULL)\n {\n ent->blacklist.current = 1;\n ent->blacklist.data[0] = '|';\n ent->blacklist.data[1] = '\\0';\n }\n else\n ent->blacklist.current = 0;\n\n if (ent->stream == NULL)\n {\n ent->stream = fopen (\"/etc/shadow\", \"rme\");\n\n if (ent->stream == NULL)\n\tstatus = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;\n else\n\t{\n\t /* We have to make sure the file is `closed on exec'. */\n\t int result = 0;\n\n\t if (__compat_have_cloexec <= 0)\n\t {\n\t int flags;\n\t result = flags = fcntl (fileno_unlocked (ent->stream), F_GETFD,\n\t\t\t\t 0);\n\t if (result >= 0)\n\t\t{\n#if defined O_CLOEXEC && !defined __ASSUME_O_CLOEXEC\n\t\t if (__compat_have_cloexec == 0)\n/* ... truncated ... */\n```\n\n### nss/nss_files/files-XXX.c\n\n#### __libc_lock_define_initialized() [lines 24-125]\n```c\n#include \"nsswitch.h\"\n\n#include <kernel-features.h>\n\n/* These symbols are defined by the including source file:\n\n ENTNAME -- database name of the structure and functions (hostent, pwent).\n STRUCTURE -- struct name, define only if not ENTNAME (passwd, group).\n DATABASE -- string of the database file's name (\"hosts\", \"passwd\").\n\n NEED_H_ERRNO - defined iff an arg `int *herrnop' is used.\n\n Also see files-parse.c.\n*/\n\n#define ENTNAME_r\tCONCAT(ENTNAME,_r)\n\n#define DATAFILE\t\"/etc/\" DATABASE\n\n#ifdef NEED_H_ERRNO\n# include <netdb.h>\n# define H_ERRNO_PROTO\t, int *herrnop\n# define H_ERRNO_ARG\t, herrnop\n# define H_ERRNO_SET(val) (*herrnop = (val))\n#else\n# define H_ERRNO_PROTO\n# define H_ERRNO_ARG\n# define H_ERRNO_SET(val) ((void) 0)\n#endif\n\n#ifndef EXTRA_ARGS\n# define EXTRA_ARGS\n# define EXTRA_ARGS_DECL\n# define EXTRA_ARGS_VALUE\n#endif\n\n/* Locks the static variables in this file. */\n__libc_lock_define_initialized (static, lock)\n\f\n/* Maintenance of the shared stream open on the database file. */\n\nstatic FILE *stream;\nstatic fpos_t position;\nstatic enum { nouse, getent, getby } last_use;\nstatic int keep_stream;\n\n/* Open database file if not already opened. */\nstatic enum nss_status\ninternal_setent (int stayopen)\n{\n enum nss_status status = NSS_STATUS_SUCCESS;\n\n if (stream == NULL)\n {\n stream = fopen (DATAFILE, \"rce\");\n\n if (stream == NULL)\n\tstatus = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;\n else\n\t{\n#if !defined O_CLOEXEC || !defined __ASSUME_O_CLOEXEC\n# ifdef O_CLOEXEC\n\t if (__have_o_cloexec <= 0)\n# endif\n\t {\n\t /* We have to make sure the file is `closed on exec'. */\n\t int result;\n\t int flags;\n\n\t result = flags = fcntl (fileno (stream), F_GETFD, 0);\n\t if (result >= 0)\n\t\t{\n# ifdef O_CLOEXEC\n\t\t if (__have_o_cloexec == 0)\n\t\t __have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1;\n\t\t if (__have_o_cloexec < 0)\n# endif\n\t\t {\n\t\t flags |= FD_CLOEXEC;\n\t\t result = fcntl (fileno (stream), F_SETFD, flags);\n\t\t }\n\t\t}\n\t if (result < 0)\n\t\t{\n\t\t /* S\n/* ... truncated ... */\n```\n\n### nss/nss_files/files-alias.c\n\n#### __libc_lock_define_initialized() [lines 1-97]\n```c\n/* Mail alias file parser in nss_files module.\n Copyright (C) 1996-2014 Free Software Foundation, Inc.\n This file is part of the GNU C Library.\n Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.\n\n The GNU C Library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation; either\n version 2.1 of the License, or (at your option) any later version.\n\n The GNU C Library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with the GNU C Library; if not, see\n <http://www.gnu.org/licenses/>. */\n\n#include <aliases.h>\n#include <ctype.h>\n#include <errno.h>\n#include <fcntl.h>\n#include <bits/libc-lock.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n\n#include <kernel-features.h>\n\n#include \"nsswitch.h\"\n\n/* Locks the static variables in this file. */\n__libc_lock_define_initialized (static, lock)\n\f\n/* Maintenance of the shared stream open on the database file. */\n\nstatic FILE *stream;\nstatic fpos_t position;\nstatic enum { nouse, getent, getby } last_use;\n\n\nstatic enum nss_status\ninternal_setent (void)\n{\n enum nss_status status = NSS_STATUS_SUCCESS;\n\n if (stream == NULL)\n {\n stream = fopen (\"/etc/aliases\", \"rce\");\n\n if (stream == NULL)\n\tstatus = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;\n else\n\t{\n#if !defined O_CLOEXEC || !defined __ASSUME_O_CLOEXEC\n# ifdef O_CLOEXEC\n\t if (__have_o_cloexec <= 0)\n# endif\n\t {\n\t /* We have to make sure the file is `closed on exec'. */\n\t int result;\n\t int flags;\n\n\t result = flags = fcntl (fileno (stream), F_GETFD, 0);\n\t if (result >= 0)\n\t\t{\n# ifdef O_CLOEXEC\n\t\t if (__have_o_cloexec == 0)\n\t\t __have_o_cloexec = (flags & FD_CLOEXEC) == \n/* ... truncated ... */\n```\n\n### nss/nss_files/files-hosts.c\n\n#### _nss_files_gethostbyname3_r() [lines 116-356]\n```c\n#undef EXTRA_ARGS_VALUE\n\nenum nss_status\n_nss_files_gethostbyname3_r (const char *name, int af, struct hostent *result,\n\t\t\t char *buffer, size_t buflen, int *errnop,\n\t\t\t int *herrnop, int32_t *ttlp, char **canonp)\n{\n uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct hostent_data);\n buffer += pad;\n buflen = buflen > pad ? buflen - pad : 0;\n\n __libc_lock_lock (lock);\n\n /* Reset file pointer to beginning or open file. */\n enum nss_status status = internal_setent (keep_stream);\n\n if (status == NSS_STATUS_SUCCESS)\n {\n /* XXX Is using _res to determine whether we want to convert IPv4\n addresses to IPv6 addresses really the right thing to do? */\n int flags = ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0);\n\n /* Tell getent function that we have repositioned the file pointer. */\n last_use = getby;\n\n while ((status = internal_getent (result, buffer, buflen, errnop,\n\t\t\t\t\therrnop, af, flags))\n\t == NSS_STATUS_SUCCESS)\n\t{\n\t LOOKUP_NAME_CASE (h_name, h_aliases)\n\t}\n\n if (status == NSS_STATUS_SUCCESS\n\t && _res_hconf.flags & HCONF_FLAG_MULTI)\n\t{\n\t /* We have to get all host entries from the file. */\n\t size_t tmp_buflen = MIN (buflen, 4096);\n\t char tmp_buffer_stack[tmp_buflen]\n\t __attribute__ ((__aligned__ (__alignof__ (struct hostent_data))));\n\t char *tmp_buffer = tmp_buffer_stack;\n/* ... 187 lines omitted ... */\n\t else\n\t status = NSS_STATUS_SUCCESS;\n\tout:\n\t if (tmp_buffer_malloced)\n\t free (tmp_buffer);\n\t}\n\n if (! keep_stream)\n\tinternal_endent ();\n }\n\n if (canonp && status == NSS_STATUS_SUCCESS)\n *canonp = result->h_name;\n\n __libc_lock_unlock (lock);\n\n return status;\n}\n\nenum nss_status\n```\n\n#### _nss_files_gethostbyname4_r() [lines 374-496]\n```c\n}\n\nenum nss_status\n_nss_files_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,\n\t\t\t char *buffer, size_t buflen, int *errnop,\n\t\t\t int *herrnop, int32_t *ttlp)\n{\n __libc_lock_lock (lock);\n\n /* Reset file pointer to beginning or open file. */\n enum nss_status status = interna\n/* ... truncated ... */\n```\n\n\n## Upstream Fix\n```diff\n[BZ #18007]\n\t* nis/nss_compat/compat-grp.c (internal_endgrent): Add parameter\n\tneedent, call nss_endgrent only if non-zero.\n\t(_nss_compat_endgrent): Pass non-zero.\n\t(_nss_compat_getgrnam_r, _nss_compat_getgrgid_r): Pass zero.\n\t* nis/nss_compat/compat-pwd.c (internal_endpwent): Add parameter\n\tneedent, call nss_endpwent only if non-zero.\n\t(_nss_compat_endpwent): Pass non-zero.\n\t(_nss_compat_getpwnam_r, _nss_compat_getpwuid_r): Pass zero.\n\t* nis/nss_compat/compat-spwd.c (internal_setspent): Add parameter\n\tneedent, call nss_setspent only if non-zero.\n\t(_nss_compat_setspent): Pass non-zero.\n\t(internal_endspent): Add parameter needent, call nss_endspent only\n\tif non-zero.\n\t(_nss_compat_endspent, _nss_compat_getspent_r): Pass non-zero.\n\t(_nss_compat_getspnam_r): Pass zero.\n\t* nss/nss_files/files-XXX.c (position, last_use, keep_stream):\n\tRemove. All uses removed.\n\t(internal_setent): Remove parameter stayopen, add parameter\n\tstream. Use it instead of global variable.\n\t(CONCAT(_nss_files_set,ENTNAME)): Pass global stream.\n\t(internal_endent, internal_getent): Add parameter stream. Use it\n\tinstead of global variable.\n\t(CONCAT(_nss_files_end,ENTNAME))\n\t(CONCAT(_nss_files_get,ENTNAME_r)): Pass global stream.\n\t(_nss_files_get##name##_r): Pass local stream. Remove locking.\n\t* nss/nss_files/files-alias.c (position, last_use): Remove. All\n\tuses removed.\n\t(internal_setent, internal_endent): Add parameter stream. Use it\n\tinstead of global variable.\n\t(_nss_files_setaliasent, _nss_files_endaliasent): Pass global\n\tstream.\n\t(get_next_alias): Add parameter stream.\n\t(_nss_files_getaliasent_r): Pass global stream.\n\t(_nss_files_getaliasbyname_r): Pass local stream. Remove locking.\n\t* nss/nss_files/files-hosts.c (_nss_files_gethostbyname3_r)\n\t(_nss_files_gethostbyname4_r): Pass local stream to\n\tinternal_setent, internal_getent and internal_endent. Remove\n\tlocking.\n\nIndex: glibc-2.19/nis/nss_compat/compat-grp.c\n===================================================================\n--- glibc-2.19.orig/nis/nss_compat/compat-grp.c\n+++ glibc-2.19/nis/nss_compat/compat-grp.c\n@@ -192,9 +192,9 @@ _nss_compat_setgrent (int stayopen)\n \n \n static enum nss_status\n-internal_endgrent (ent_t *ent)\n+internal_endgrent (ent_t *ent, int needent)\n {\n- if (nss_endgrent)\n+ if (needent && nss_endgrent)\n nss_endgrent ();\n \n if (ent->stream != NULL)\n@@ -222,7 +222,7 @@ _nss_compat_endgrent (void)\n \n __libc_lock_lock (lock);\n \n- result = internal_endgrent (&ext_ent);\n+ result = internal_endgrent (&ext_ent, 1);\n \n __libc_lock_unlock (lock);\n \n@@ -532,7 +532,7 @@ _nss_compat_getgrnam_r (const char *name\n if (result == NSS_STATUS_SUCCESS)\n result = internal_getgrnam_r (name, grp, &ent, buffer, buflen, errnop);\n \n- internal_endgrent (&ent);\n+ internal_endgrent (&ent, 0);\n \n return result;\n }\n@@ -661,7 +661,7 @@ _nss_compat_getgrgid_r (gid_t gid, struc\n if (result == NSS_STATUS_SUCCESS)\n result = internal_getgrgid_r (gid, grp, &ent, buffer, buflen, errnop);\n \n- internal_endgrent (&ent);\n+ internal_endgrent (&ent, 0);\n \n return result;\n }\nIndex: glibc-2.19/nis/nss_compat/compat-pwd.c\n===================================================================\n--- glibc-2.19.orig/nis/nss_compat/compat-pwd.c\n+++ glibc-2.19/nis/nss_compat/compat-pwd.c\n@@ -309,9 +309,9 @@ _nss_compat_setpwent (int stayopen)\n \n \n static enum nss_status\n-internal_endpwent (ent_t *ent)\n+internal_endpwent (ent_t *ent, int needent)\n {\n- if (nss_endpwent)\n+ if (needent && nss_endpwent)\n nss_endpwent ();\n \n if (ent->stream != NULL)\n@@ -346,7 +346,7 @@ _nss_compat_endpwent (void)\n \n __libc_lock_lock (lock);\n \n- result = internal_endpwent (&ext_ent);\n+ result = internal_endpwent (&ext_ent, 1);\n \n __libc_lock_unlock (lock);\n \n@@ -871,7 +871,7 @@ _nss_compat_getpwnam_r (const char *name\n if (result == NSS_STATUS_SUCCESS)\n result = internal_getpwnam_r (name, pwd, &ent, buffer, buflen, errnop);\n \n- internal_endpwent (&ent);\n+ internal_endpwent (&ent, 0);\n \n return result;\n }\n@@ -1110,7 +1110,7 @@ _nss_compat_getpwuid_r (uid_t uid, struc\n if (result == NSS_STATUS_SUCCESS)\n result = internal_getpwuid_r (uid, pwd, &ent, buffer, buflen, errnop);\n \n- internal_endpwent (&ent);\n+ internal_endpwent (&ent, 0);\n \n return result;\n }\nIndex: glibc-2.19/nis/nss_compat/compat-spwd.c\n===================================================================\n--- glibc-2.19.orig/nis/nss_compat/compat-spwd.c\n+++ glibc-2.19/nis/nss_compat/compat-spwd.c\n@@ -169,7 +169,7 @@ copy_spwd_changes (struct spwd *dest, st\n }\n \n static enum nss_status\n-internal_setspent (ent_t *ent, int stayopen)\n+internal_setspent (ent_t *ent, int stayopen, int needent)\n {\n enum nss_status status = NSS_STATUS_SUCCESS;\n \n@@ -239,7 +239,7 @@ internal_setspent (ent_t *ent, int stayo\n \n give_spwd_free (&ent->pwd);\n \n- if (status == NSS_STATUS_SUCCESS && nss_setspent)\n+ if (needent && status == NSS_STATUS_SUCCESS && nss_setspent)\n ent->setent_status = nss_setspent (stayopen);\n \n return status;\n@@ -256,7 +256,7 @@ _nss_compat_setspent (int stayopen)\n if (ni == NULL)\n init_nss_interface ();\n \n- result = internal_setspent (&ext_ent, stayopen);\n+ result = internal_setspent (&ext_ent, stayopen, 1);\n \n __libc_lock_unlock (lock);\n \n@@ -265,9 +265,9 @@ _nss_compat_setspent (int stayopen)\n \n \n static enum nss_status\n-internal_endspent (ent_t *ent)\n+internal_endspent (ent_t *ent, int needent)\n {\n- if (nss_endspent)\n+ if (needent && nss_endspent)\n nss_endspent ();\n \n if (ent->stream != NULL)\n@@ -303,7 +303,7 @@ _nss_compat_endspent (void)\n \n __libc_lock_lock (lock);\n \n- result = internal_endspent (&ext_ent);\n+ result = internal_endspent (&ext_ent, 1);\n \n __libc_lock_unlock (lock);\n \n@@ -658,7 +658,7 @@ _nss_compat_getspent_r (struct spwd *pwd\n init_nss_interface ();\n \n if (ext_ent.stream == NULL)\n- result = internal_setspent (&ext_ent, 1);\n+ result = internal_setspent (&ext_ent, 1, 1);\n \n if (result == NSS_STATUS_SUCCESS)\n result = internal_getspent_r (pwd, &ext_ent, buffer, buflen, errnop);\n@@ -830,12 +830,12 @@ _nss_compat_getspnam_r (const char *name\n \n __libc_lock_unlock (lock);\n \n- result = internal_setspent (&ent, 0);\n+ result = internal_setspent (&ent, 0, 0);\n \n if (result == NSS_STATUS_SUCCESS)\n result = internal_getspnam_r (name, pwd, &ent, buffer, buflen, errnop);\n \n- internal_endspent (&ent);\n+ internal_endspent (&ent, 0);\n \n return result;\n }\nIndex: glibc-2.19/nss/nss_files/files-XXX.c\n===================================================================\n--- glibc-2.19.orig/nss/nss_files/files-XXX.c\n+++ glibc-2.19/nss/nss_files/files-XXX.c\n@@ -63,21 +63,18 @@ __libc_lock_define_initialized (static,\n /* Maintenance of the shared stream open on the database file. */\n \n static FILE *stream;\n-static fpos_t position;\n-static enum { nouse, getent, getby } last_use;\n-static int keep_stream;\n \n /* Open database file if not already opened. */\n static enum nss_status\n-internal_setent (int stayopen)\n+internal_setent (FILE **stream)\n {\n enum nss_status status = NSS_STATUS_SUCCESS;\n \n- if (stream == NULL)\n+ if (*stream == NULL)\n {\n- stream = fopen (DATAFILE, \"rce\");\n+ *stream = fopen (DATAFILE, \"rce\");\n \n- if (stream == NULL)\n+ if (*stream == NULL)\n \tstatus = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;\n else\n \t{\n@@ -90,7 +87,7 @@ internal_setent (int stayopen)\n \t int result;\n \t int flags;\n \n-\t result = flags = fcntl (fileno (stream), F_GETFD, 0);\n+\t result = flags = fcntl (fileno (*stream), F_GETFD, 0);\n \t if (result >= 0)\n \t\t{\n # ifdef O_CLOEXEC\n@@ -100,15 +97,15 @@ internal_setent (int stayopen)\n # endif\n \t\t {\n \t\t flags |= FD_CLOEXEC;\n-\t\t result = fcntl (fileno (stream), F_SETFD, flags);\n+\t\t result = fcntl (fileno (*stream), F_SETFD, flags);\n \t\t }\n \t\t}\n \t if (result < 0)\n \t\t{\n \t\t /* Something went wrong. Close the stream and return a\n \t\t failure. */\n-\t\t fclose (stream);\n-\n... (truncated)\n```\n\nGenerate a backported patch for the SUSE target version."
},
{
"role": "assistant",
"content": "[BZ #18007]\n\t* nis/nss_compat/compat-grp.c (internal_endgrent): Add parameter\n\tneedent, call nss_endgrent only if non-zero.\n\t(_nss_compat_endgrent): Pass non-zero.\n\t(_nss_compat_getgrnam_r, _nss_compat_getgrgid_r): Pass zero.\n\t* nis/nss_compat/compat-pwd.c (internal_endpwent): Add parameter\n\tneedent, call nss_endpwent only if non-zero.\n\t(_nss_compat_endpwent): Pass non-zero.\n\t(_nss_compat_getpwnam_r, _nss_compat_getpwuid_r): Pass zero.\n\t* nis/nss_compat/compat-spwd.c (internal_setspent): Add parameter\n\tneedent, call nss_setspent only if non-zero.\n\t(_nss_compat_setspent): Pass non-zero.\n\t(internal_endspent): Add parameter needent, call nss_endspent only\n\tif non-zero.\n\t(_nss_compat_endspent, _nss_compat_getspent_r): Pass non-zero.\n\t(_nss_compat_getspnam_r): Pass zero.\n\t* nss/nss_files/files-XXX.c (position, last_use, keep_stream):\n\tRemove. All uses removed.\n\t(internal_setent): Remove parameter stayopen, add parameter\n\tstream. Use it instead of global variable.\n\t(CONCAT(_nss_files_set,ENTNAME)): Pass global stream.\n\t(internal_endent, internal_getent): Add parameter stream. Use it\n\tinstead of global variable.\n\t(CONCAT(_nss_files_end,ENTNAME))\n\t(CONCAT(_nss_files_get,ENTNAME_r)): Pass global stream.\n\t(_nss_files_get##name##_r): Pass local stream. Remove locking.\n\t* nss/nss_files/files-alias.c (position, last_use): Remove. All\n\tuses removed.\n\t(internal_setent, internal_endent): Add parameter stream. Use it\n\tinstead of global variable.\n\t(_nss_files_setaliasent, _nss_files_endaliasent): Pass global\n\tstream.\n\t(get_next_alias): Add parameter stream.\n\t(_nss_files_getaliasent_r): Pass global stream.\n\t(_nss_files_getaliasbyname_r): Pass local stream. Remove locking.\n\t* nss/nss_files/files-hosts.c (_nss_files_gethostbyname3_r)\n\t(_nss_files_gethostbyname4_r): Pass local stream to\n\tinternal_setent, internal_getent and internal_endent. Remove\n\tlocking.\n\nIndex: glibc-2.19/nis/nss_compat/compat-grp.c\n===================================================================\n--- glibc-2.19.orig/nis/nss_compat/compat-grp.c\n+++ glibc-2.19/nis/nss_compat/compat-grp.c\n@@ -192,9 +192,9 @@ _nss_compat_setgrent (int stayopen)\n \n \n static enum nss_status\n-internal_endgrent (ent_t *ent)\n+internal_endgrent (ent_t *ent, int needent)\n {\n- if (nss_endgrent)\n+ if (needent && nss_endgrent)\n nss_endgrent ();\n \n if (ent->stream != NULL)\n@@ -222,7 +222,7 @@ _nss_compat_endgrent (void)\n \n __libc_lock_lock (lock);\n \n- result = internal_endgrent (&ext_ent);\n+ result = internal_endgrent (&ext_ent, 1);\n \n __libc_lock_unlock (lock);\n \n@@ -532,7 +532,7 @@ _nss_compat_getgrnam_r (const char *name\n if (result == NSS_STATUS_SUCCESS)\n result = internal_getgrnam_r (name, grp, &ent, buffer, buflen, errnop);\n \n- internal_endgrent (&ent);\n+ internal_endgrent (&ent, 0);\n \n return result;\n }\n@@ -661,7 +661,7 @@ _nss_compat_getgrgid_r (gid_t gid, struc\n if (result == NSS_STATUS_SUCCESS)\n result = internal_getgrgid_r (gid, grp, &ent, buffer, buflen, errnop);\n \n- internal_endgrent (&ent);\n+ internal_endgrent (&ent, 0);\n \n return result;\n }\nIndex: glibc-2.19/nis/nss_compat/compat-pwd.c\n===================================================================\n--- glibc-2.19.orig/nis/nss_compat/compat-pwd.c\n+++ glibc-2.19/nis/nss_compat/compat-pwd.c\n@@ -309,9 +309,9 @@ _nss_compat_setpwent (int stayopen)\n \n \n static enum nss_status\n-internal_endpwent (ent_t *ent)\n+internal_endpwent (ent_t *ent, int needent)\n {\n- if (nss_endpwent)\n+ if (needent && nss_endpwent)\n nss_endpwent ();\n \n if (ent->stream != NULL)\n@@ -346,7 +346,7 @@ _nss_compat_endpwent (void)\n \n __libc_lock_lock (lock);\n \n- result = internal_endpwent (&ext_ent);\n+ result = internal_endpwent (&ext_ent, 1);\n \n __libc_lock_unlock (lock);\n \n@@ -871,7 +871,7 @@ _nss_compat_getpwnam_r (const char *name\n if (result == NSS_STATUS_SUCCESS)\n result = internal_getpwnam_r (name, pwd, &ent, buffer, buflen, errnop);\n \n- internal_endpwent (&ent);\n+ internal_endpwent (&ent, 0);\n \n return result;\n }\n@@ -1110,7 +1110,7 @@ _nss_compat_getpwuid_r (uid_t uid, struc\n if (result == NSS_STATUS_SUCCESS)\n result = internal_getpwuid_r (uid, pwd, &ent, buffer, buflen, errnop);\n \n- internal_endpwent (&ent);\n+ internal_endpwent (&ent, 0);\n \n return result;\n }\nIndex: glibc-2.19/nis/nss_compat/compat-spwd.c\n===================================================================\n--- glibc-2.19.orig/nis/nss_compat/compat-spwd.c\n+++ glibc-2.19/nis/nss_compat/compat-spwd.c\n@@ -169,7 +169,7 @@ copy_spwd_changes (struct spwd *dest, st\n }\n \n static enum nss_status\n-internal_setspent (ent_t *ent, int stayopen)\n+internal_setspent (ent_t *ent, int stayopen, int needent)\n {\n enum nss_status status = NSS_STATUS_SUCCESS;\n \n@@ -239,7 +239,7 @@ internal_setspent (ent_t *ent, int stayo\n \n give_spwd_free (&ent->pwd);\n \n- if (status == NSS_STATUS_SUCCESS && nss_setspent)\n+ if (needent && status == NSS_STATUS_SUCCESS && nss_setspent)\n ent->setent_status = nss_setspent (stayopen);\n \n return status;\n@@ -256,7 +256,7 @@ _nss_compat_setspent (int stayopen)\n if (ni == NULL)\n init_nss_interface ();\n \n- result = internal_setspent (&ext_ent, stayopen);\n+ result = internal_setspent (&ext_ent, stayopen, 1);\n \n __libc_lock_unlock (lock);\n \n@@ -265,9 +265,9 @@ _nss_compat_setspent (int stayopen)\n \n \n static enum nss_status\n-internal_endspent (ent_t *ent)\n+internal_endspent (ent_t *ent, int needent)\n {\n- if (nss_endspent)\n+ if (needent && nss_endspent)\n nss_endspent ();\n \n if (ent->stream != NULL)\n@@ -303,7 +303,7 @@ _nss_compat_endspent (void)\n \n __libc_lock_lock (lock);\n \n- result = internal_endspent (&ext_ent);\n+ result = internal_endspent (&ext_ent, 1);\n \n __libc_lock_unlock (lock);\n \n@@ -658,7 +658,7 @@ _nss_compat_getspent_r (struct spwd *pwd\n init_nss_interface ();\n \n if (ext_ent.stream == NULL)\n- result = internal_setspent (&ext_ent, 1);\n+ result = internal_setspent (&ext_ent, 1, 1);\n \n if (result == NSS_STATUS_SUCCESS)\n result = internal_getspent_r (pwd, &ext_ent, buffer, buflen, errnop);\n@@ -830,12 +830,12 @@ _nss_compat_getspnam_r (const char *name\n \n __libc_lock_unlock (lock);\n \n- result = internal_setspent (&ent, 0);\n+ result = internal_setspent (&ent, 0, 0);\n \n if (result == NSS_STATUS_SUCCESS)\n result = internal_getspnam_r (name, pwd, &ent, buffer, buflen, errnop);\n \n- internal_endspent (&ent);\n+ internal_endspent (&ent, 0);\n \n return result;\n }\nIndex: glibc-2.19/nss/nss_files/files-XXX.c\n===================================================================\n--- glibc-2.19.orig/nss/nss_files/files-XXX.c\n+++ glibc-2.19/nss/nss_files/files-XXX.c\n@@ -63,21 +63,18 @@ __libc_lock_define_initialized (static,\n /* Maintenance of the shared stream open on the database file. */\n \n static FILE *stream;\n-static fpos_t position;\n-static enum { nouse, getent, getby } last_use;\n-static int keep_stream;\n \n /* Open database file if not already opened. */\n static enum nss_status\n-internal_setent (int stayopen)\n+internal_setent (FILE **stream)\n {\n enum nss_status status = NSS_STATUS_SUCCESS;\n \n- if (stream == NULL)\n+ if (*stream == NULL)\n {\n- stream = fopen (DATAFILE, \"rce\");\n+ *stream = fopen (DATAFILE, \"rce\");\n \n- if (stream == NULL)\n+ if (*stream == NULL)\n \tstatus = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;\n else\n \t{\n@@ -90,7 +87,7 @@ internal_setent (int stayopen)\n \t int result;\n \t int flags;\n \n-\t result = flags = fcntl (fileno (stream), F_GETFD, 0);\n+\t result = flags = fcntl (fileno (*stream), F_GETFD, 0);\n \t if (result >= 0)\n \t\t{\n # ifdef O_CLOEXEC\n@@ -100,15 +97,15 @@ internal_setent (int stayopen)\n # endif\n \t\t {\n \t\t flags |= FD_CLOEXEC;\n-\t\t result = fcntl (fileno (stream), F_SETFD, flags);\n+\t\t result = fcntl (fileno (*stream), F_SETFD, flags);\n \t\t }\n \t\t}\n \t if (result < 0)\n \t\t{\n \t\t /* Something went wrong. Close the stream and return a\n \t\t failure. */\n-\t\t fclose (stream);\n-\t\t stream = NULL;\n+\t\t fclose (*stream);\n+\t\t *stream = NULL;\n \t\t status = NSS_STATUS_UNAVAIL;\n \t\t}\n \t }\n@@ -116,11 +113,7 @@ internal_setent (int stayopen)\n \t}\n }\n else\n- rewind (stream);\n-\n- /* Remember STAYOPEN flag. */\n- if (stream != NULL)\n- keep_stream |= stayopen;\n+ rewind (*stream);\n \n return status;\n }\n@@ -134,16 +127,7 @@ CONCAT(_nss_files_set,ENTNAME) (int stay\n \n __libc_lock_lock (lock);\n \n- status = internal_setent (stayopen);\n-\n- if (status == NSS_STATUS_SUCCESS && fgetpos (stream, &position) < 0)\n- {\n- fclose (stream);\n- stream = NULL;\n- status = NSS_STATUS_UNAVAIL;\n- }\n-\n- last_use = getent;\n+ status = internal_setent (&stream);\n \n __libc_lock_unlock (lock);\n \n@@ -153,12 +137,12 @@ CONCAT(_nss_files_set,ENTNAME) (int stay\n \n /* Close the database file. */\n static void\n-internal_endent (void)\n+internal_endent (FILE **stream)\n {\n- if (stream != NULL)\n+ if (*stream != NULL)\n {\n- fclose (stream);\n- stream = NULL;\n+ fclose (*stream);\n+ *stream = NULL;\n }\n }\n \n@@ -169,10 +153,7 @@ CONCAT(_nss_files_end,ENTNAME) (void)\n {\n __libc_lock_lock (lock);\n \n- internal_endent ();\n-\n- /* Reset STAYOPEN flag. */\n- keep_stream = 0;\n+ internal_endent (&stream);\n \n __libc_lock_unlock (lock);\n \n@@ -227,7 +208,7 @@ get_contents (char *linebuf, size_t len,\n \n /* Parsing the database file into `struct STRUCTURE' data structures. */\n static enum nss_status\n-internal_getent (struct STRUCTURE *result,\n+internal_getent (FILE *stream, struct STRUCTURE *result,\n \t\t char *buffer, size_t buflen, int *errnop H_ERRNO_PROTO\n \t\t EXTRA_ARGS_DECL)\n {\n@@ -300,45 +281,14 @@ CONCAT(_nss_files_get,ENTNAME_r) (struct\n {\n int save_errno = errno;\n \n- status = internal_setent (0);\n+ status = internal_setent (&stream);\n \n __set_errno (save_errno);\n-\n- if (status == NSS_STATUS_SUCCESS && fgetpos (stream, &position) < 0)\n-\t{\n-\t fclose (stream);\n-\t stream = NULL;\n-\t status = NSS_STATUS_UNAVAIL;\n-\t}\n }\n \n if (status == NSS_STATUS_SUCCESS)\n- {\n- /* If the last use was not by the getent function we need the\n-\t position the stream. */\n- if (last_use != getent)\n-\t{\n-\t if (fsetpos (stream, &position) < 0)\n-\t status = NSS_STATUS_UNAVAIL;\n-\t else\n-\t last_use = getent;\n-\t}\n-\n- if (status == NSS_STATUS_SUCCESS)\n-\t{\n-\t status = internal_getent (result, buffer, buflen, errnop\n-\t\t\t\t H_ERRNO_ARG EXTRA_ARGS_VALUE);\n-\n-\t /* Remember this position if we were successful. If the\n-\t operation failed we give the user a chance to repeat the\n-\t operation (perhaps the buffer was too small). */\n-\t if (status == NSS_STATUS_SUCCESS)\n-\t fgetpos (stream, &position);\n-\t else\n-\t /* We must make sure we reposition the stream the next call. */\n-\t last_use = nouse;\n-\t}\n- }\n+ status = internal_getent (stream, result, buffer, buflen, errnop\n+\t\t\t H_ERRNO_ARG EXTRA_ARGS_VALUE);\n \n __libc_lock_unlock (lock);\n \n@@ -364,27 +314,20 @@ _nss_files_get##name##_r (proto,\n \t\t\t size_t buflen, int *errnop H_ERRNO_PROTO)\t \\\n {\t\t\t\t\t\t\t\t\t \\\n enum nss_status status;\t\t\t\t\t\t \\\n+ FILE *stream = NULL;\t\t\t\t\t\t\t \\\n \t\t\t\t\t\t\t\t\t \\\n- __libc_lock_lock (lock);\t\t\t\t\t\t \\\n-\t\t\t\t\t\t\t\t\t \\\n- /* Reset file pointer to beginning or open file. */\t\t\t \\\n- status = internal_setent (keep_stream);\t\t\t\t \\\n+ /* Open file. */\t\t\t\t\t\t\t \\\n+ status = internal_setent (&stream);\t\t\t\t\t \\\n \t\t\t\t\t\t\t\t\t \\\n if (status == NSS_STATUS_SUCCESS)\t\t\t\t\t \\\n {\t\t\t\t\t\t\t\t\t \\\n- /* Tell getent function that we have repositioned the file pointer. */ \\\n- last_use = getby;\t\t\t\t\t\t\t \\\n-\t\t\t\t\t\t\t\t\t \\\n- while ((status = internal_getent (result, buffer, buflen, errnop\t \\\n+ while ((status = internal_getent (stream, result, buffer, buflen, errnop \\\n \t\t\t\t\tH_ERRNO_ARG EXTRA_ARGS_VALUE))\t \\\n \t == NSS_STATUS_SUCCESS)\t\t\t\t\t \\\n \t{ break_if_match }\t\t\t\t\t\t \\\n \t\t\t\t\t\t\t\t\t \\\n- if (! keep_stream)\t\t\t\t\t\t \\\n-\tinternal_endent ();\t\t\t\t\t\t \\\n+ internal_endent (&stream);\t\t\t\t\t \\\n }\t\t\t\t\t\t\t\t\t \\\n \t\t\t\t\t\t\t\t\t \\\n- __libc_lock_unlock (lock);\t\t\t\t\t\t \\\n-\t\t\t\t\t\t\t\t\t \\\n return status;\t\t\t\t\t\t\t \\\n }\nIndex: glibc-2.19/nss/nss_files/files-alias.c\n===================================================================\n--- glibc-2.19.orig/nss/nss_files/files-alias.c\n+++ glibc-2.19/nss/nss_files/files-alias.c\n@@ -36,20 +36,18 @@ __libc_lock_define_initialized (static,\n /* Maintenance of the shared stream open on the database file. */\n \n static FILE *stream;\n-static fpos_t position;\n-static enum { nouse, getent, getby } last_use;\n \n \n static enum nss_status\n-internal_setent (void)\n+internal_setent (FILE **stream)\n {\n enum nss_status status = NSS_STATUS_SUCCESS;\n \n- if (stream == NULL)\n+ if (*stream == NULL)\n {\n- stream = fopen (\"/etc/aliases\", \"rce\");\n+ *stream = fopen (\"/etc/aliases\", \"rce\");\n \n- if (stream == NULL)\n+ if (*stream == NULL)\n \tstatus = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;\n else\n \t{\n@@ -62,7 +60,7 @@ internal_setent (void)\n \t int result;\n \t int flags;\n \n-\t result = flags = fcntl (fileno (stream), F_GETFD, 0);\n+\t result = flags = fcntl (fileno (*stream), F_GETFD, 0);\n \t if (result >= 0)\n \t\t{\n # ifdef O_CLOEXEC\n@@ -72,14 +70,14 @@ internal_setent (void)\n # endif\n \t\t {\n \t\t flags |= FD_CLOEXEC;\n-\t\t result = fcntl (fileno (stream), F_SETFD, flags);\n+\t\t result = fcntl (fileno (*stream), F_SETFD, flags);\n \t\t }\n \t\t}\n \t if (result < 0)\n \t\t{\n \t\t /* Something went wrong. Close the stream and return a\n \t\t failure. */\n-\t\t fclose (stream);\n+\t\t fclose (*stream);\n \t\t stream = NULL;\n \t\t status = NSS_STATUS_UNAVAIL;\n \t\t}\n@@ -88,7 +86,7 @@ internal_setent (void)\n \t}\n }\n else\n- rewind (stream);\n+ rewind (*stream);\n \n return status;\n }\n@@ -102,16 +100,7 @@ _nss_files_setaliasent (void)\n \n __libc_lock_lock (lock);\n \n- status = internal_setent ();\n-\n- if (status == NSS_STATUS_SUCCESS && fgetpos (stream, &position) < 0)\n- {\n- fclose (stream);\n- stream = NULL;\n- status = NSS_STATUS_UNAVAIL;\n- }\n-\n- last_use = getent;\n+ status = internal_setent (&stream);\n \n __libc_lock_unlock (lock);\n \n@@ -121,12 +110,12 @@ _nss_files_setaliasent (void)\n \n /* Close the database file. */\n static void\n-internal_endent (void)\n+internal_endent (FILE **stream)\n {\n- if (stream != NULL)\n+ if (*stream != NULL)\n {\n- fclose (stream);\n- stream = NULL;\n+ fclose (*stream);\n+ *stream = NULL;\n }\n }\n \n@@ -137,7 +126,7 @@ _nss_files_endaliasent (void)\n {\n __libc_lock_lock (lock);\n \n- internal_endent ();\n+ internal_endent (&stream);\n \n __libc_lock_unlock (lock);\n \n@@ -146,7 +135,7 @@ _nss_files_endaliasent (void)\n \f\n /* Parsing the database file into `struct aliasent' data structures. */\n static enum nss_status\n-get_next_alias (const char *match, struct aliasent *result,\n+get_next_alias (FILE *stream, const char *match, struct aliasent *result,\n \t\tchar *buffer, size_t buflen, int *errnop)\n {\n enum nss_status status = NSS_STATUS_NOTFOUND;\n@@ -397,35 +386,16 @@ _nss_files_getaliasent_r (struct aliasen\n \n /* Be prepared that the set*ent function was not called before. */\n if (stream == NULL)\n- status = internal_setent ();\n+ status = internal_setent (&stream);\n \n if (status == NSS_STATUS_SUCCESS)\n {\n- /* If the last use was not by the getent function we need the\n-\t position the stream. */\n- if (last_use != getent)\n-\t{\n-\t if (fsetpos (stream, &position) < 0)\n-\t status = NSS_STATUS_UNAVAIL;\n-\t else\n-\t last_use = getent;\n-\t}\n-\n- if (status == NSS_STATUS_SUCCESS)\n-\t{\n-\t result->alias_local = 1;\n+ result->alias_local = 1;\n \n-\t /* Read lines until we get a definite result. */\n-\t do\n-\t status = get_next_alias (NULL, result, buffer, buflen, errnop);\n-\t while (status == NSS_STATUS_RETURN);\n-\n-\t /* If we successfully read an entry remember this position. */\n-\t if (status == NSS_STATUS_SUCCESS)\n-\t fgetpos (stream, &position);\n-\t else\n-\t last_use = nouse;\n-\t}\n+ /* Read lines until we get a definite result. */\n+ do\n+\tstatus = get_next_alias (stream, NULL, result, buffer, buflen, errnop);\n+ while (status == NSS_STATUS_RETURN);\n }\n \n __libc_lock_unlock (lock);\n@@ -440,6 +410,7 @@ _nss_files_getaliasbyname_r (const char\n {\n /* Return next entry in host file. */\n enum nss_status status = NSS_STATUS_SUCCESS;\n+ FILE *stream = NULL;\n \n if (name == NULL)\n {\n@@ -447,11 +418,8 @@ _nss_files_getaliasbyname_r (const char\n return NSS_STATUS_UNAVAIL;\n }\n \n- __libc_lock_lock (lock);\n-\n- /* Open the stream or rest it. */\n- status = internal_setent ();\n- last_use = getby;\n+ /* Open the stream. */\n+ status = internal_setent (&stream);\n \n if (status == NSS_STATUS_SUCCESS)\n {\n@@ -459,13 +427,11 @@ _nss_files_getaliasbyname_r (const char\n \n /* Read lines until we get a definite result. */\n do\n-\tstatus = get_next_alias (name, result, buffer, buflen, errnop);\n+\tstatus = get_next_alias (stream, name, result, buffer, buflen, errnop);\n while (status == NSS_STATUS_RETURN);\n }\n \n- internal_endent ();\n-\n- __libc_lock_unlock (lock);\n+ internal_endent (&stream);\n \n return status;\n }\nIndex: glibc-2.19/nss/nss_files/files-hosts.c\n===================================================================\n--- glibc-2.19.orig/nss/nss_files/files-hosts.c\n+++ glibc-2.19/nss/nss_files/files-hosts.c\n@@ -115,14 +115,13 @@ _nss_files_gethostbyname3_r (const char\n \t\t\t char *buffer, size_t buflen, int *errnop,\n \t\t\t int *herrnop, int32_t *ttlp, char **canonp)\n {\n+ FILE *stream = NULL;\n uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct hostent_data);\n buffer += pad;\n buflen = buflen > pad ? buflen - pad : 0;\n \n- __libc_lock_lock (lock);\n-\n- /* Reset file pointer to beginning or open file. */\n- enum nss_status status = internal_setent (keep_stream);\n+ /* Open file. */\n+ enum nss_status status = internal_setent (&stream);\n \n if (status == NSS_STATUS_SUCCESS)\n {\n@@ -130,10 +129,7 @@ _nss_files_gethostbyname3_r (const char\n addresses to IPv6 addresses really the right thing to do? */\n int flags = ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0);\n \n- /* Tell getent function that we have repositioned the file pointer. */\n- last_use = getby;\n-\n- while ((status = internal_getent (result, buffer, buflen, errnop,\n+ while ((status = internal_getent (stream, result, buffer, buflen, errnop,\n \t\t\t\t\therrnop, af, flags))\n \t == NSS_STATUS_SUCCESS)\n \t{\n@@ -160,7 +156,7 @@ _nss_files_gethostbyname3_r (const char\n \t bufferend = (char *) &result->h_aliases[naliases + 1];\n \n \tagain:\n-\t while ((status = internal_getent (&tmp_result_buf, tmp_buffer,\n+\t while ((status = internal_getent (stream, &tmp_result_buf, tmp_buffer,\n \t\t\t\t\t tmp_buflen, errnop, herrnop, af,\n \t\t\t\t\t flags))\n \t\t == NSS_STATUS_SUCCESS)\n@@ -336,15 +332,12 @@ _nss_files_gethostbyname3_r (const char\n \t free (tmp_buffer);\n \t}\n \n- if (! keep_stream)\n-\tinternal_endent ();\n+ internal_endent (&stream);\n }\n \n if (canonp && status == NSS_STATUS_SUCCESS)\n *canonp = result->h_name;\n \n- __libc_lock_unlock (lock);\n-\n return status;\n }\n \n@@ -373,16 +366,13 @@ _nss_files_gethostbyname4_r (const char\n \t\t\t char *buffer, size_t buflen, int *errnop,\n \t\t\t int *herrnop, int32_t *ttlp)\n {\n- __libc_lock_lock (lock);\n+ FILE *stream = NULL;\n \n- /* Reset file pointer to beginning or open file. */\n- enum nss_status status = internal_setent (keep_stream);\n+ /* Open file. */\n+ enum nss_status status = internal_setent (&stream);\n \n if (status == NSS_STATUS_SUCCESS)\n {\n- /* Tell getent function that we have repositioned the file pointer. */\n- last_use = getby;\n-\n bool any = false;\n bool got_canon = false;\n while (1)\n@@ -394,7 +384,7 @@ _nss_files_gethostbyname4_r (const char\n \t buflen = buflen > pad ? buflen - pad : 0;\n \n \t struct hostent result;\n-\t status = internal_getent (&result, buffer, buflen, errnop,\n+\t status = internal_getent (stream, &result, buffer, buflen, errnop,\n \t\t\t\t herrnop, AF_UNSPEC, 0);\n \t if (status != NSS_STATUS_SUCCESS)\n \t break;\n@@ -470,8 +460,7 @@ _nss_files_gethostbyname4_r (const char\n \t status = NSS_STATUS_SUCCESS;\n \t}\n \n- if (! keep_stream)\n-\tinternal_endent ();\n+ internal_endent (&stream);\n }\n else if (status == NSS_STATUS_TRYAGAIN)\n {\n@@ -484,7 +473,5 @@ _nss_files_gethostbyname4_r (const char\n *herrnop = NO_DATA;\n }\n \n- __libc_lock_unlock (lock);\n-\n return status;\n }"
}
] |
{
"id": "glibc-testsuite-5158-nss-separate-state-getXXent.pa",
"cve_id": "CVE-2016-3706",
"package": "glibc-testsuite",
"tier": "adapted",
"has_source_context": true,
"context_tokens_est": 3175,
"context_files": 6,
"license": "LGPL-2.1-or-later",
"upstream_enriched": null,
"upstream_commit": null,
"upstream_repo": null
}
|
[
{
"role": "system",
"content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."
},
{
"role": "user",
"content": "## CVE: CVE-2016-0747\n\nThe resolver in nginx before 1.8.1 and 1.9.x before 1.9.10 does not properly limit CNAME resolution, which allows remote attackers to cause a denial of service (worker process resource consumption) via vectors related to arbitrary name resolution.\n\n## Package\nnginx\n\n## Files to modify\n- passenger/ext/nginx/Configuration.c\n- passenger.orig/ext/nginx/Configuration.c\n\n## Upstream Fix\n```diff\nIndex: passenger/ext/nginx/Configuration.c\n===================================================================\n--- passenger.orig/ext/nginx/Configuration.c\t2015-06-24 23:29:12.725985654 +0800\n+++ passenger/ext/nginx/Configuration.c\t2015-06-24 23:02:39.654901783 +0800\n@@ -261,7 +261,11 @@\n conf->upstream_config.pass_request_body = NGX_CONF_UNSET;\n \n #if (NGX_HTTP_CACHE)\n- conf->upstream_config.cache = NGX_CONF_UNSET_PTR;\n+ #if NGINX_VERSION_NUM >= 1007009\n+ \tconf->upstream_config.cache = NGX_CONF_UNSET_PTR;\n+ #else\n+ \tconf->upstream_config.cache = NGX_CONF_UNSET;\n+ #endif\n conf->upstream_config.cache_min_uses = NGX_CONF_UNSET_UINT;\n conf->upstream_config.cache_bypass = NGX_CONF_UNSET_PTR;\n conf->upstream_config.no_cache = NGX_CONF_UNSET_PTR;\n@@ -270,6 +274,9 @@\n conf->upstream_config.cache_lock = NGX_CONF_UNSET;\n conf->upstream_config.cache_lock_timeout = NGX_CONF_UNSET_MSEC;\n #endif\n+ #if NGINX_VERSION_NUM >= 1007008\n+ \tconf->upstream_config.cache_lock_age = NGX_CONF_UNSET_MSEC;\n+ #endif\n #endif\n \n conf->upstream_config.intercept_errors = NGX_CONF_UNSET;\n@@ -374,15 +381,34 @@\n /******************************/\n /******************************/\n \n- if (conf->upstream_config.store != 0) {\n- ngx_conf_merge_value(conf->upstream_config.store,\n- prev->upstream_config.store, 0);\n+ #if (NGX_HTTP_CACHE) && NGINX_VERSION_NUM >= 1007009\n+ if (conf->upstream_config.store > 0) {\n+ conf->upstream_config.cache = 0;\n+ }\n+ if (conf->upstream_config.cache > 0) {\n+ conf->upstream_config.store = 0;\n+ }\n+ #endif\n+\n+ #if NGINX_VERSION_NUM >= 1007009\n+ if (conf->upstream_config.store == NGX_CONF_UNSET) {\n+ ngx_conf_merge_value(conf->upstream_config.store,\n+ prev->upstream_config.store, 0);\n \n- if (conf->upstream_config.store_lengths == NULL) {\n conf->upstream_config.store_lengths = prev->upstream_config.store_lengths;\n conf->upstream_config.store_values = prev->upstream_config.store_values;\n }\n- }\n+ #else\n+ if (conf->upstream_config.store != 0) {\n+ ngx_conf_merge_value(conf->upstream_config.store,\n+ prev->upstream_config.store, 0);\n+\n+ if (conf->upstream_config.store_lengths == NULL) {\n+ conf->upstream_config.store_lengths = prev->upstream_config.store_lengths;\n+ conf->upstream_config.store_values = prev->upstream_config.store_values;\n+ }\n+ }\n+ #endif\n \n ngx_conf_merge_uint_value(conf->upstream_config.store_access,\n prev->upstream_config.store_access, 0600);\n@@ -526,20 +552,42 @@\n \n #if (NGX_HTTP_CACHE)\n \n- ngx_conf_merge_ptr_value(conf->upstream_config.cache,\n- prev->upstream_config.cache, NULL);\n+ #if NGINX_VERSION_NUM >= 1007009\n+ if (conf->upstream_config.cache == NGX_CONF_UNSET) {\n+ ngx_conf_merge_value(conf->upstream_config.cache,\n+ prev->upstream_config.cache, 0);\n+\n+ conf->upstream_config.cache_zone = prev->upstream_config.cache_zone;\n+ conf->upstream_config.cache_value = prev->upstream_config.cache_value;\n+ }\n \n- if (conf->upstream_config.cache && conf->upstream_config.cache->data == NULL) {\n- ngx_shm_zone_t *shm_zone;\n+\tif (conf->upstream_config.cache_zone && conf->upstream_config.cache_zone->data == NULL) {\n+ ngx_shm_zone_t *shm_zone;\n \n- shm_zone = conf->upstream_config.cache;\n+ shm_zone = conf->upstream_config.cache_zone;\n \n ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n- \"\\\"scgi_cache\\\" zone \\\"%V\\\" is unknown\",\n- &shm_zone->shm.name);\n+ \"\\\"scgi_cache\\\" zone \\\"%V\\\" is unknown\",\n+ &shm_zone->shm.name);\n \n- return NGX_CONF_ERROR;\n- }\n+ return NGX_CONF_ERROR;\n+ }\n+ #else\n+ ngx_conf_merge_ptr_value(conf->upstream_config.cache,\n+ prev->upstream_config.cache, NULL);\n+\n+ if (conf->upstream_config.cache && conf->upstream_config.cache->data == NULL) {\n+ ngx_shm_zone_t *shm_zone;\n+\n+ shm_zone = conf->upstream_config.cache;\n+\n+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n+ \"\\\"scgi_cache\\\" zone \\\"%V\\\" is unknown\",\n+ &shm_zone->shm.name);\n+\n+ return NGX_CONF_ERROR;\n+ }\n+ #endif\n \n ngx_conf_merge_uint_value(conf->upstream_config.cache_min_uses,\n prev->upstream_config.cache_min_uses, 1);\n@@ -585,6 +633,11 @@\n prev->upstream_config.cache_lock_timeout, 5000);\n #endif\n \n+ #if NGINX_VERSION_NUM >= 1007008\n+ ngx_conf_merge_msec_value(conf->upstream_config.cache_lock_age,\n+ prev->upstream_config.cache_lock_age, 5000);\n+ #endif\n+\n #endif\n \n ngx_conf_merge_value(conf->upstream_config.pass_request_headers,\n```\n\nGenerate a backported patch for the SUSE target version."
},
{
"role": "assistant",
"content": "Index: passenger/ext/nginx/Configuration.c\n===================================================================\n--- passenger.orig/ext/nginx/Configuration.c\t2015-06-24 23:29:12.725985654 +0800\n+++ passenger/ext/nginx/Configuration.c\t2015-06-24 23:02:39.654901783 +0800\n@@ -261,7 +261,11 @@\n conf->upstream_config.pass_request_body = NGX_CONF_UNSET;\n \n #if (NGX_HTTP_CACHE)\n- conf->upstream_config.cache = NGX_CONF_UNSET_PTR;\n+ #if NGINX_VERSION_NUM >= 1007009\n+ \tconf->upstream_config.cache = NGX_CONF_UNSET_PTR;\n+ #else\n+ \tconf->upstream_config.cache = NGX_CONF_UNSET;\n+ #endif\n conf->upstream_config.cache_min_uses = NGX_CONF_UNSET_UINT;\n conf->upstream_config.cache_bypass = NGX_CONF_UNSET_PTR;\n conf->upstream_config.no_cache = NGX_CONF_UNSET_PTR;\n@@ -270,6 +274,9 @@\n conf->upstream_config.cache_lock = NGX_CONF_UNSET;\n conf->upstream_config.cache_lock_timeout = NGX_CONF_UNSET_MSEC;\n #endif\n+ #if NGINX_VERSION_NUM >= 1007008\n+ \tconf->upstream_config.cache_lock_age = NGX_CONF_UNSET_MSEC;\n+ #endif\n #endif\n \n conf->upstream_config.intercept_errors = NGX_CONF_UNSET;\n@@ -374,15 +381,34 @@\n /******************************/\n /******************************/\n \n- if (conf->upstream_config.store != 0) {\n- ngx_conf_merge_value(conf->upstream_config.store,\n- prev->upstream_config.store, 0);\n+ #if (NGX_HTTP_CACHE) && NGINX_VERSION_NUM >= 1007009\n+ if (conf->upstream_config.store > 0) {\n+ conf->upstream_config.cache = 0;\n+ }\n+ if (conf->upstream_config.cache > 0) {\n+ conf->upstream_config.store = 0;\n+ }\n+ #endif\n+\n+ #if NGINX_VERSION_NUM >= 1007009\n+ if (conf->upstream_config.store == NGX_CONF_UNSET) {\n+ ngx_conf_merge_value(conf->upstream_config.store,\n+ prev->upstream_config.store, 0);\n \n- if (conf->upstream_config.store_lengths == NULL) {\n conf->upstream_config.store_lengths = prev->upstream_config.store_lengths;\n conf->upstream_config.store_values = prev->upstream_config.store_values;\n }\n- }\n+ #else\n+ if (conf->upstream_config.store != 0) {\n+ ngx_conf_merge_value(conf->upstream_config.store,\n+ prev->upstream_config.store, 0);\n+\n+ if (conf->upstream_config.store_lengths == NULL) {\n+ conf->upstream_config.store_lengths = prev->upstream_config.store_lengths;\n+ conf->upstream_config.store_values = prev->upstream_config.store_values;\n+ }\n+ }\n+ #endif\n \n ngx_conf_merge_uint_value(conf->upstream_config.store_access,\n prev->upstream_config.store_access, 0600);\n@@ -526,20 +552,42 @@\n \n #if (NGX_HTTP_CACHE)\n \n- ngx_conf_merge_ptr_value(conf->upstream_config.cache,\n- prev->upstream_config.cache, NULL);\n+ #if NGINX_VERSION_NUM >= 1007009\n+ if (conf->upstream_config.cache == NGX_CONF_UNSET) {\n+ ngx_conf_merge_value(conf->upstream_config.cache,\n+ prev->upstream_config.cache, 0);\n+\n+ conf->upstream_config.cache_zone = prev->upstream_config.cache_zone;\n+ conf->upstream_config.cache_value = prev->upstream_config.cache_value;\n+ }\n \n- if (conf->upstream_config.cache && conf->upstream_config.cache->data == NULL) {\n- ngx_shm_zone_t *shm_zone;\n+\tif (conf->upstream_config.cache_zone && conf->upstream_config.cache_zone->data == NULL) {\n+ ngx_shm_zone_t *shm_zone;\n \n- shm_zone = conf->upstream_config.cache;\n+ shm_zone = conf->upstream_config.cache_zone;\n \n ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n- \"\\\"scgi_cache\\\" zone \\\"%V\\\" is unknown\",\n- &shm_zone->shm.name);\n+ \"\\\"scgi_cache\\\" zone \\\"%V\\\" is unknown\",\n+ &shm_zone->shm.name);\n \n- return NGX_CONF_ERROR;\n- }\n+ return NGX_CONF_ERROR;\n+ }\n+ #else\n+ ngx_conf_merge_ptr_value(conf->upstream_config.cache,\n+ prev->upstream_config.cache, NULL);\n+\n+ if (conf->upstream_config.cache && conf->upstream_config.cache->data == NULL) {\n+ ngx_shm_zone_t *shm_zone;\n+\n+ shm_zone = conf->upstream_config.cache;\n+\n+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n+ \"\\\"scgi_cache\\\" zone \\\"%V\\\" is unknown\",\n+ &shm_zone->shm.name);\n+\n+ return NGX_CONF_ERROR;\n+ }\n+ #endif\n \n ngx_conf_merge_uint_value(conf->upstream_config.cache_min_uses,\n prev->upstream_config.cache_min_uses, 1);\n@@ -585,6 +633,11 @@\n prev->upstream_config.cache_lock_timeout, 5000);\n #endif\n \n+ #if NGINX_VERSION_NUM >= 1007008\n+ ngx_conf_merge_msec_value(conf->upstream_config.cache_lock_age,\n+ prev->upstream_config.cache_lock_age, 5000);\n+ #endif\n+\n #endif\n \n ngx_conf_merge_value(conf->upstream_config.pass_request_headers,"
}
] |
{
"id": "nginx-4606-nginx-1.8.0-passenger-4.0.18.p",
"cve_id": "CVE-2016-0747",
"package": "nginx",
"tier": "identical",
"has_source_context": false,
"context_tokens_est": null,
"context_files": null,
"license": "BSD-2-Clause",
"upstream_enriched": null,
"upstream_commit": null,
"upstream_repo": null
}
|
[
{
"role": "system",
"content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."
},
{
"role": "user",
"content": "## CVE: CVE-2016-5384\n\nfontconfig before 2.12.1 does not validate offsets, which allows local users to trigger arbitrary free calls and consequently conduct double free attacks and execute arbitrary code via a crafted cache file.\n\n## Package\nfontconfig\n\n## Upstream Fix\n```diff\nFrom 74b9be6b4030ac1bfd4c20b52bbcdeb66373eaba Mon Sep 17 00:00:00 2001\nFrom: Frederic Crozat <fcrozat@suse.com>\nDate: Fri, 6 Dec 2013 14:23:52 +0100\nSubject: [PATCH 2/2] Add metric aliases for additional Google ChromeOS fonts\n\nMS fonts Cambria, Symbol and Calibri have compat metrics fonts\nfrom ChromeOS.\n---\n conf.d/30-metric-aliases.conf | 43 +++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 43 insertions(+)\n\ndiff --git a/conf.d/30-metric-aliases.conf b/conf.d/30-metric-aliases.conf\nindex c9ee79f..49a9602 100644\n--- a/conf.d/30-metric-aliases.conf\n+++ b/conf.d/30-metric-aliases.conf\n@@ -24,6 +24,9 @@ Arial Liberation Sans Arimo Albany\n Arial Narrow Liberation Sans Narrow\n Times New Roman Liberation Serif Tinos Thorndale Thorndale AMT\n Courier New Liberation Mono Cousine Cumberland Cumberland AMT\n+Cambria Caladea\n+Calibri Carlito\n+Symbol SymbolNeu\n \n Microsoft fonts: Other fonts:\n ================ ============\n@@ -307,7 +310,26 @@ but in an order preferring similar designs first. We do this in three steps:\n \t </default>\n \t</alias>\n \n+\t<alias binding=\"same\">\n+\t <family>Caladea</family>\n+\t <default>\n+\t <family>Cambria</family>\n+\t </default>\n+\t</alias>\n \n+\t<alias binding=\"same\">\n+\t <family>Carlito</family>\n+\t <default>\n+\t <family>Calibri</family>\n+\t </default>\n+\t</alias>\n+\n+\t<alias binding=\"same\">\n+\t <family>SymbolNeu</family>\n+\t <default>\n+\t <family>Symbol</family>\n+\t </default>\n+ </alias>\n \n <!-- Accept the other group as fallback -->\n \n@@ -494,4 +516,25 @@ but in an order preferring similar designs first. We do this in three steps:\n \t </accept>\n \t</alias>\n \n+\t<alias binding=\"same\">\n+\t <family>Cambria</family>\n+\t <accept>\n+\t <family>Caladea</family>\n+\t </accept>\n+\t</alias>\n+\n+\t<alias binding=\"same\">\n+\t <family>Calibri</family>\n+\t <accept>\n+\t <family>Carlito</family>\n+\t </accept>\n+ </alias>\n+\n+\t<alias binding=\"same\">\n+\t <family>Symbol</family>\n+\t <accept>\n+\t <family>SymbolNeu</family>\n+\t </accept>\n+ </alias>\n+\n </fontconfig>\n-- \n1.8.4\n```\n\nGenerate a backported patch for the SUSE target version."
},
{
"role": "assistant",
"content": "From 74b9be6b4030ac1bfd4c20b52bbcdeb66373eaba Mon Sep 17 00:00:00 2001\nFrom: Frederic Crozat <fcrozat@suse.com>\nDate: Fri, 6 Dec 2013 14:23:52 +0100\nSubject: [PATCH 2/2] Add metric aliases for additional Google ChromeOS fonts\n\nMS fonts Cambria, Symbol and Calibri have compat metrics fonts\nfrom ChromeOS.\n---\n conf.d/30-metric-aliases.conf | 43 +++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 43 insertions(+)\n\ndiff --git a/conf.d/30-metric-aliases.conf b/conf.d/30-metric-aliases.conf\nindex c9ee79f..49a9602 100644\n--- a/conf.d/30-metric-aliases.conf\n+++ b/conf.d/30-metric-aliases.conf\n@@ -24,6 +24,9 @@ Arial Liberation Sans Arimo Albany\n Arial Narrow Liberation Sans Narrow\n Times New Roman Liberation Serif Tinos Thorndale Thorndale AMT\n Courier New Liberation Mono Cousine Cumberland Cumberland AMT\n+Cambria Caladea\n+Calibri Carlito\n+Symbol SymbolNeu\n \n Microsoft fonts: Other fonts:\n ================ ============\n@@ -307,7 +310,26 @@ but in an order preferring similar designs first. We do this in three steps:\n \t </default>\n \t</alias>\n \n+\t<alias binding=\"same\">\n+\t <family>Caladea</family>\n+\t <default>\n+\t <family>Cambria</family>\n+\t </default>\n+\t</alias>\n \n+\t<alias binding=\"same\">\n+\t <family>Carlito</family>\n+\t <default>\n+\t <family>Calibri</family>\n+\t </default>\n+\t</alias>\n+\n+\t<alias binding=\"same\">\n+\t <family>SymbolNeu</family>\n+\t <default>\n+\t <family>Symbol</family>\n+\t </default>\n+ </alias>\n \n <!-- Accept the other group as fallback -->\n \n@@ -494,4 +516,25 @@ but in an order preferring similar designs first. We do this in three steps:\n \t </accept>\n \t</alias>\n \n+\t<alias binding=\"same\">\n+\t <family>Cambria</family>\n+\t <accept>\n+\t <family>Caladea</family>\n+\t </accept>\n+\t</alias>\n+\n+\t<alias binding=\"same\">\n+\t <family>Calibri</family>\n+\t <accept>\n+\t <family>Carlito</family>\n+\t </accept>\n+ </alias>\n+\n+\t<alias binding=\"same\">\n+\t <family>Symbol</family>\n+\t <accept>\n+\t <family>SymbolNeu</family>\n+\t </accept>\n+ </alias>\n+\n </fontconfig>\n-- \n1.8.4"
}
] |
{
"id": "fontconfig-5559-0002-Add-metric-aliases-for-ad",
"cve_id": "CVE-2016-5384",
"package": "fontconfig",
"tier": "identical",
"has_source_context": false,
"context_tokens_est": null,
"context_files": null,
"license": "MIT",
"upstream_enriched": null,
"upstream_commit": null,
"upstream_repo": null
}
|
[
{
"role": "system",
"content": "You are a security patch backporting assistant for SUSE/openSUSE.\n\nGiven a CVE description and an upstream fix, adapt the patch to work with\nthe target SUSE package version. Output the backported patch in unified\ndiff format. If the upstream fix applies directly, output it unchanged."
},
{
"role": "user",
"content": "## CVE: CVE-2015-8325\n\nThe do_setup_env function in session.c in sshd in OpenSSH through 7.2p2, when the UseLogin feature is enabled and PAM is configured to read .pam_environment files in user home directories, allows local users to gain privileges by triggering a crafted environment for the /bin/login program, as demonstrated by an LD_PRELOAD environment variable.\n\n## Package\nopenssh-askpass-gnome\n\n## Files to modify\n- openssh-6.6p1/readconf.h\n- openssh-6.6p1/readconf.c\n- openssh-6.6p1/servconf.c\n- openssh-6.6p1/auth2.c\n- openssh-6.6p1/servconf.h\n\n## Upstream Fix\n```diff\n# HG changeset patch\n# Parent 3aa40f8165fb2e63e4842e9b7643e4ca48b7bb51\n# The patch below adds support for the deprecated 'gssapi' authentication\n# mechanism to OpenSSH 3.8p1. The newer 'gssapi-with-mic' mechanism is included\n# in this release. The use of 'gssapi' is deprecated due to the presence of\n# potential man-in-the-middle attacks, which 'gssapi-with-mic' is not\n# susceptible to.\n#\n# To use the patch apply it to a OpenSSH 3.8p1 source tree. After compiling,\n# backwards compatibility may be obtained by supplying the\n# 'GssapiEnableMitmAttack yes' option to either the client or server.\n#\n# It should be noted that this patch is being made available purely as a means\n# of easing the process of moving to OpenSSH 3.8p1. Any new installations are\n# recommended to use the 'gssapi-with-mic' mechanism. Existing installations\n# are encouraged to upgrade as soon as possible.\n\ndiff --git a/openssh-6.6p1/auth2-gss.c b/openssh-6.6p1/auth2-gss.c\n--- a/openssh-6.6p1/auth2-gss.c\n+++ b/openssh-6.6p1/auth2-gss.c\n@@ -168,16 +168,25 @@ input_gssapi_token(int type, u_int32_t p\n \t\t\tdispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL);\n \t\t\tif (flags & GSS_C_INTEG_FLAG)\n \t\t\t\tdispatch_set(SSH2_MSG_USERAUTH_GSSAPI_MIC,\n \t\t\t\t &input_gssapi_mic);\n \t\t\telse\n \t\t\t\tdispatch_set(\n \t\t\t\t SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE,\n \t\t\t\t &input_gssapi_exchange_complete);\n+\n+\t\t\t/* \n+\t\t\t * Old style 'gssapi' didn't have the GSSAPI_MIC \n+\t\t\t * and went straight to sending exchange_complete \n+\t\t\t */\n+\t\t\tif (options.gss_enable_mitm)\n+\t\t\t\tdispatch_set(\n+\t\t\t\t SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE,\n+\t\t\t\t &input_gssapi_exchange_complete);\n \t\t}\n \t}\n \n \tgss_release_buffer(&min_status, &send_tok);\n }\n \n static void\n input_gssapi_errtok(int type, u_int32_t plen, void *ctxt)\n@@ -286,9 +295,15 @@ input_gssapi_mic(int type, u_int32_t ple\n }\n \n Authmethod method_gssapi = {\n \t\"gssapi-with-mic\",\n \tuserauth_gssapi,\n \t&options.gss_authentication\n };\n \n+Authmethod method_gssapi_old = {\n+\t\"gssapi\",\n+\tuserauth_gssapi,\n+\t&options.gss_enable_mitm\n+};\n+\n #endif /* GSSAPI */\ndiff --git a/openssh-6.6p1/auth2.c b/openssh-6.6p1/auth2.c\n--- a/openssh-6.6p1/auth2.c\n+++ b/openssh-6.6p1/auth2.c\n@@ -65,23 +65,25 @@ extern Buffer loginmsg;\n \n extern Authmethod method_none;\n extern Authmethod method_pubkey;\n extern Authmethod method_passwd;\n extern Authmethod method_kbdint;\n extern Authmethod method_hostbased;\n #ifdef GSSAPI\n extern Authmethod method_gssapi;\n+extern Authmethod method_gssapi_old;\n #endif\n \n Authmethod *authmethods[] = {\n \t&method_none,\n \t&method_pubkey,\n #ifdef GSSAPI\n \t&method_gssapi,\n+\t&method_gssapi_old,\n #endif\n \t&method_passwd,\n \t&method_kbdint,\n \t&method_hostbased,\n \tNULL\n };\n \n /* protocol */\ndiff --git a/openssh-6.6p1/readconf.c b/openssh-6.6p1/readconf.c\n--- a/openssh-6.6p1/readconf.c\n+++ b/openssh-6.6p1/readconf.c\n@@ -135,17 +135,17 @@ typedef enum {\n \toCompressionLevel, oTCPKeepAlive, oNumberOfPasswordPrompts,\n \toUsePrivilegedPort, oLogLevel, oCiphers, oProtocol, oMacs,\n \toGlobalKnownHostsFile2, oUserKnownHostsFile2, oPubkeyAuthentication,\n \toKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias,\n \toDynamicForward, oPreferredAuthentications, oHostbasedAuthentication,\n \toHostKeyAlgorithms, oBindAddress, oPKCS11Provider,\n \toClearAllForwardings, oNoHostAuthenticationForLocalhost,\n \toEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,\n-\toAddressFamily, oGssAuthentication, oGssDelegateCreds,\n+\toAddressFamily, oGssAuthentication, oGssDelegateCreds, oGssEnableMITM,\n \toServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,\n \toSendEnv, oControlPath, oControlMaster, oControlPersist,\n \toHashKnownHosts,\n \toTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand,\n \toVisualHostKey, oUseRoaming,\n \toKexAlgorithms, oIPQoS, oRequestTTY, oIgnoreUnknown, oProxyUseFdpass,\n \toCanonicalDomains, oCanonicalizeHostname, oCanonicalizeMaxDots,\n \toCanonicalizeFallbackLocal, oCanonicalizePermittedCNAMEs,\n@@ -179,19 +179,21 @@ static struct {\n \t{ \"skeyauthentication\", oChallengeResponseAuthentication }, /* alias */\n \t{ \"tisauthentication\", oChallengeResponseAuthentication }, /* alias */\n \t{ \"kerberosauthentication\", oUnsupported },\n \t{ \"kerberostgtpassing\", oUnsupported },\n \t{ \"afstokenpassing\", oUnsupported },\n #if defined(GSSAPI)\n \t{ \"gssapiauthentication\", oGssAuthentication },\n \t{ \"gssapidelegatecredentials\", oGssDelegateCreds },\n+\t{ \"gssapienablemitmattack\", oGssEnableMITM },\n #else\n \t{ \"gssapiauthentication\", oUnsupported },\n \t{ \"gssapidelegatecredentials\", oUnsupported },\n+\t{ \"gssapienablemitmattack\", oUnsupported },\n #endif\n \t{ \"fallbacktorsh\", oDeprecated },\n \t{ \"usersh\", oDeprecated },\n \t{ \"identityfile\", oIdentityFile },\n \t{ \"identityfile2\", oIdentityFile },\t\t\t/* obsolete */\n \t{ \"identitiesonly\", oIdentitiesOnly },\n \t{ \"hostname\", oHostName },\n \t{ \"hostkeyalias\", oHostKeyAlias },\n@@ -839,16 +841,20 @@ parse_time:\n \n \tcase oGssAuthentication:\n \t\tintptr = &options->gss_authentication;\n \t\tgoto parse_flag;\n \n \tcase oGssDelegateCreds:\n \t\tintptr = &options->gss_deleg_creds;\n \t\tgoto parse_flag;\n+\t\t\n+\tcase oGssEnableMITM:\n+\t\tintptr = &options->gss_enable_mitm;\n+\t\tgoto parse_flag;\n \n \tcase oBatchMode:\n \t\tintptr = &options->batch_mode;\n \t\tgoto parse_flag;\n \n \tcase oCheckHostIP:\n \t\tintptr = &options->check_host_ip;\n \t\tgoto parse_flag;\n@@ -1493,16 +1499,17 @@ initialize_options(Options * options)\n \toptions->xauth_location = NULL;\n \toptions->gateway_ports = -1;\n \toptions->use_privileged_port = -1;\n \toptions->rsa_authentication = -1;\n \toptions->pubkey_authentication = -1;\n \toptions->challenge_response_authentication = -1;\n \toptions->gss_authentication = -1;\n \toptions->gss_deleg_creds = -1;\n+\toptions->gss_enable_mitm = -1;\n \toptions->password_authentication = -1;\n \toptions->kbd_interactive_authentication = -1;\n \toptions->kbd_interactive_devices = NULL;\n \toptions->rhosts_rsa_authentication = -1;\n \toptions->hostbased_authentication = -1;\n \toptions->batch_mode = -1;\n \toptions->check_host_ip = -1;\n \toptions->strict_host_key_checking = -1;\n@@ -1613,16 +1620,18 @@ fill_default_options(Options * options)\n \tif (options->pubkey_authentication == -1)\n \t\toptions->pubkey_authentication = 1;\n \tif (options->challenge_response_authentication == -1)\n \t\toptions->challenge_response_authentication = 1;\n \tif (options->gss_authentication == -1)\n \t\toptions->gss_authentication = 0;\n \tif (options->gss_deleg_creds == -1)\n \t\toptions->gss_deleg_creds = 0;\n+\tif (options->gss_enable_mitm == -1)\n+\t\toptions->gss_enable_mitm = 0;\n \tif (options->password_authentication == -1)\n \t\toptions->password_authentication = 1;\n \tif (options->kbd_interactive_authentication == -1)\n \t\toptions->kbd_interactive_authentication = 1;\n \tif (options->rhosts_rsa_authentication == -1)\n \t\toptions->rhosts_rsa_authentication = 0;\n \tif (options->hostbased_authentication == -1)\n \t\toptions->hostbased_authentication = 0;\ndiff --git a/openssh-6.6p1/readconf.h b/openssh-6.6p1/readconf.h\n--- a/openssh-6.6p1/readconf.h\n+++ b/openssh-6.6p1/readconf.h\n@@ -50,16 +50,17 @@ typedef struct {\n \t\t\t\t\t\t * authentication. */\n \tint rsa_authentication;\t/* Try RSA authentication. */\n \tint pubkey_authentication;\t/* Try ssh2 pubkey authentication. */\n \tint hostbased_authentication;\t/* ssh2's rhosts_rsa */\n \tint challenge_response_authentication;\n \t\t\t\t\t/* Try S/Key or TIS, authentication. */\n \tint gss_authentication;\t/* Try GSS authentication */\n \tint gss_deleg_creds;\t/* Delegate GSS credentials */\n+\tint \tgss_enable_mitm;\t/* Enable old style gssapi auth */\n \tint password_authentication;\t/* Try password\n \t\t\t\t\t\t * authentication. */\n \tint kbd_interactive_authentication; /* Try keyboard-interactive auth. */\n \tchar\t*kbd_interactive_devices; /* Keyboard-interactive auth devices. */\n \tint batch_mode;\t/* Batch mode: do not ask for passwords. */\n \tint check_host_ip;\t/* Also keep track of keys for IP address */\n \tint strict_host_key_checking;\t/* Strict host key checking. */\n \tint compression;\t/* Compress packets in\n... (truncated)\n```\n\nGenerate a backported patch for the SUSE target version."
},
{
"role": "assistant",
"content": "# HG changeset patch\n# Parent 3aa40f8165fb2e63e4842e9b7643e4ca48b7bb51\n# The patch below adds support for the deprecated 'gssapi' authentication\n# mechanism to OpenSSH 3.8p1. The newer 'gssapi-with-mic' mechanism is included\n# in this release. The use of 'gssapi' is deprecated due to the presence of\n# potential man-in-the-middle attacks, which 'gssapi-with-mic' is not\n# susceptible to.\n#\n# To use the patch apply it to a OpenSSH 3.8p1 source tree. After compiling,\n# backwards compatibility may be obtained by supplying the\n# 'GssapiEnableMitmAttack yes' option to either the client or server.\n#\n# It should be noted that this patch is being made available purely as a means\n# of easing the process of moving to OpenSSH 3.8p1. Any new installations are\n# recommended to use the 'gssapi-with-mic' mechanism. Existing installations\n# are encouraged to upgrade as soon as possible.\n\ndiff --git a/openssh-6.6p1/auth2-gss.c b/openssh-6.6p1/auth2-gss.c\n--- a/openssh-6.6p1/auth2-gss.c\n+++ b/openssh-6.6p1/auth2-gss.c\n@@ -168,16 +168,25 @@ input_gssapi_token(int type, u_int32_t p\n \t\t\tdispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL);\n \t\t\tif (flags & GSS_C_INTEG_FLAG)\n \t\t\t\tdispatch_set(SSH2_MSG_USERAUTH_GSSAPI_MIC,\n \t\t\t\t &input_gssapi_mic);\n \t\t\telse\n \t\t\t\tdispatch_set(\n \t\t\t\t SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE,\n \t\t\t\t &input_gssapi_exchange_complete);\n+\n+\t\t\t/* \n+\t\t\t * Old style 'gssapi' didn't have the GSSAPI_MIC \n+\t\t\t * and went straight to sending exchange_complete \n+\t\t\t */\n+\t\t\tif (options.gss_enable_mitm)\n+\t\t\t\tdispatch_set(\n+\t\t\t\t SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE,\n+\t\t\t\t &input_gssapi_exchange_complete);\n \t\t}\n \t}\n \n \tgss_release_buffer(&min_status, &send_tok);\n }\n \n static void\n input_gssapi_errtok(int type, u_int32_t plen, void *ctxt)\n@@ -286,9 +295,15 @@ input_gssapi_mic(int type, u_int32_t ple\n }\n \n Authmethod method_gssapi = {\n \t\"gssapi-with-mic\",\n \tuserauth_gssapi,\n \t&options.gss_authentication\n };\n \n+Authmethod method_gssapi_old = {\n+\t\"gssapi\",\n+\tuserauth_gssapi,\n+\t&options.gss_enable_mitm\n+};\n+\n #endif /* GSSAPI */\ndiff --git a/openssh-6.6p1/auth2.c b/openssh-6.6p1/auth2.c\n--- a/openssh-6.6p1/auth2.c\n+++ b/openssh-6.6p1/auth2.c\n@@ -65,23 +65,25 @@ extern Buffer loginmsg;\n \n extern Authmethod method_none;\n extern Authmethod method_pubkey;\n extern Authmethod method_passwd;\n extern Authmethod method_kbdint;\n extern Authmethod method_hostbased;\n #ifdef GSSAPI\n extern Authmethod method_gssapi;\n+extern Authmethod method_gssapi_old;\n #endif\n \n Authmethod *authmethods[] = {\n \t&method_none,\n \t&method_pubkey,\n #ifdef GSSAPI\n \t&method_gssapi,\n+\t&method_gssapi_old,\n #endif\n \t&method_passwd,\n \t&method_kbdint,\n \t&method_hostbased,\n \tNULL\n };\n \n /* protocol */\ndiff --git a/openssh-6.6p1/readconf.c b/openssh-6.6p1/readconf.c\n--- a/openssh-6.6p1/readconf.c\n+++ b/openssh-6.6p1/readconf.c\n@@ -135,17 +135,17 @@ typedef enum {\n \toCompressionLevel, oTCPKeepAlive, oNumberOfPasswordPrompts,\n \toUsePrivilegedPort, oLogLevel, oCiphers, oProtocol, oMacs,\n \toGlobalKnownHostsFile2, oUserKnownHostsFile2, oPubkeyAuthentication,\n \toKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias,\n \toDynamicForward, oPreferredAuthentications, oHostbasedAuthentication,\n \toHostKeyAlgorithms, oBindAddress, oPKCS11Provider,\n \toClearAllForwardings, oNoHostAuthenticationForLocalhost,\n \toEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,\n-\toAddressFamily, oGssAuthentication, oGssDelegateCreds,\n+\toAddressFamily, oGssAuthentication, oGssDelegateCreds, oGssEnableMITM,\n \toServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,\n \toSendEnv, oControlPath, oControlMaster, oControlPersist,\n \toHashKnownHosts,\n \toTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand,\n \toVisualHostKey, oUseRoaming,\n \toKexAlgorithms, oIPQoS, oRequestTTY, oIgnoreUnknown, oProxyUseFdpass,\n \toCanonicalDomains, oCanonicalizeHostname, oCanonicalizeMaxDots,\n \toCanonicalizeFallbackLocal, oCanonicalizePermittedCNAMEs,\n@@ -179,19 +179,21 @@ static struct {\n \t{ \"skeyauthentication\", oChallengeResponseAuthentication }, /* alias */\n \t{ \"tisauthentication\", oChallengeResponseAuthentication }, /* alias */\n \t{ \"kerberosauthentication\", oUnsupported },\n \t{ \"kerberostgtpassing\", oUnsupported },\n \t{ \"afstokenpassing\", oUnsupported },\n #if defined(GSSAPI)\n \t{ \"gssapiauthentication\", oGssAuthentication },\n \t{ \"gssapidelegatecredentials\", oGssDelegateCreds },\n+\t{ \"gssapienablemitmattack\", oGssEnableMITM },\n #else\n \t{ \"gssapiauthentication\", oUnsupported },\n \t{ \"gssapidelegatecredentials\", oUnsupported },\n+\t{ \"gssapienablemitmattack\", oUnsupported },\n #endif\n \t{ \"fallbacktorsh\", oDeprecated },\n \t{ \"usersh\", oDeprecated },\n \t{ \"identityfile\", oIdentityFile },\n \t{ \"identityfile2\", oIdentityFile },\t\t\t/* obsolete */\n \t{ \"identitiesonly\", oIdentitiesOnly },\n \t{ \"hostname\", oHostName },\n \t{ \"hostkeyalias\", oHostKeyAlias },\n@@ -839,16 +841,20 @@ parse_time:\n \n \tcase oGssAuthentication:\n \t\tintptr = &options->gss_authentication;\n \t\tgoto parse_flag;\n \n \tcase oGssDelegateCreds:\n \t\tintptr = &options->gss_deleg_creds;\n \t\tgoto parse_flag;\n+\t\t\n+\tcase oGssEnableMITM:\n+\t\tintptr = &options->gss_enable_mitm;\n+\t\tgoto parse_flag;\n \n \tcase oBatchMode:\n \t\tintptr = &options->batch_mode;\n \t\tgoto parse_flag;\n \n \tcase oCheckHostIP:\n \t\tintptr = &options->check_host_ip;\n \t\tgoto parse_flag;\n@@ -1493,16 +1499,17 @@ initialize_options(Options * options)\n \toptions->xauth_location = NULL;\n \toptions->gateway_ports = -1;\n \toptions->use_privileged_port = -1;\n \toptions->rsa_authentication = -1;\n \toptions->pubkey_authentication = -1;\n \toptions->challenge_response_authentication = -1;\n \toptions->gss_authentication = -1;\n \toptions->gss_deleg_creds = -1;\n+\toptions->gss_enable_mitm = -1;\n \toptions->password_authentication = -1;\n \toptions->kbd_interactive_authentication = -1;\n \toptions->kbd_interactive_devices = NULL;\n \toptions->rhosts_rsa_authentication = -1;\n \toptions->hostbased_authentication = -1;\n \toptions->batch_mode = -1;\n \toptions->check_host_ip = -1;\n \toptions->strict_host_key_checking = -1;\n@@ -1613,16 +1620,18 @@ fill_default_options(Options * options)\n \tif (options->pubkey_authentication == -1)\n \t\toptions->pubkey_authentication = 1;\n \tif (options->challenge_response_authentication == -1)\n \t\toptions->challenge_response_authentication = 1;\n \tif (options->gss_authentication == -1)\n \t\toptions->gss_authentication = 0;\n \tif (options->gss_deleg_creds == -1)\n \t\toptions->gss_deleg_creds = 0;\n+\tif (options->gss_enable_mitm == -1)\n+\t\toptions->gss_enable_mitm = 0;\n \tif (options->password_authentication == -1)\n \t\toptions->password_authentication = 1;\n \tif (options->kbd_interactive_authentication == -1)\n \t\toptions->kbd_interactive_authentication = 1;\n \tif (options->rhosts_rsa_authentication == -1)\n \t\toptions->rhosts_rsa_authentication = 0;\n \tif (options->hostbased_authentication == -1)\n \t\toptions->hostbased_authentication = 0;\ndiff --git a/openssh-6.6p1/readconf.h b/openssh-6.6p1/readconf.h\n--- a/openssh-6.6p1/readconf.h\n+++ b/openssh-6.6p1/readconf.h\n@@ -50,16 +50,17 @@ typedef struct {\n \t\t\t\t\t\t * authentication. */\n \tint rsa_authentication;\t/* Try RSA authentication. */\n \tint pubkey_authentication;\t/* Try ssh2 pubkey authentication. */\n \tint hostbased_authentication;\t/* ssh2's rhosts_rsa */\n \tint challenge_response_authentication;\n \t\t\t\t\t/* Try S/Key or TIS, authentication. */\n \tint gss_authentication;\t/* Try GSS authentication */\n \tint gss_deleg_creds;\t/* Delegate GSS credentials */\n+\tint \tgss_enable_mitm;\t/* Enable old style gssapi auth */\n \tint password_authentication;\t/* Try password\n \t\t\t\t\t\t * authentication. */\n \tint kbd_interactive_authentication; /* Try keyboard-interactive auth. */\n \tchar\t*kbd_interactive_devices; /* Keyboard-interactive auth devices. */\n \tint batch_mode;\t/* Batch mode: do not ask for passwords. */\n \tint check_host_ip;\t/* Also keep track of keys for IP address */\n \tint strict_host_key_checking;\t/* Strict host key checking. */\n \tint compression;\t/* Compress packets in both directions. */\ndiff --git a/openssh-6.6p1/servconf.c b/openssh-6.6p1/servconf.c\n--- a/openssh-6.6p1/servconf.c\n+++ b/openssh-6.6p1/servconf.c\n@@ -104,16 +104,17 @@ initialize_server_options(ServerOptions \n \toptions->rsa_authentication = -1;\n \toptions->pubkey_authentication = -1;\n \toptions->kerberos_authentication = -1;\n \toptions->kerberos_or_local_passwd = -1;\n \toptions->kerberos_ticket_cleanup = -1;\n \toptions->kerberos_get_afs_token = -1;\n \toptions->gss_authentication=-1;\n \toptions->gss_cleanup_creds = -1;\n+\toptions->gss_enable_mitm = -1;\n \toptions->password_authentication = -1;\n \toptions->kbd_interactive_authentication = -1;\n \toptions->challenge_response_authentication = -1;\n \toptions->permit_empty_passwd = -1;\n \toptions->permit_user_env = -1;\n \toptions->use_login = -1;\n \toptions->compression = -1;\n \toptions->rekey_limit = -1;\n@@ -241,16 +242,18 @@ fill_default_server_options(ServerOption\n \tif (options->kerberos_ticket_cleanup == -1)\n \t\toptions->kerberos_ticket_cleanup = 1;\n \tif (options->kerberos_get_afs_token == -1)\n \t\toptions->kerberos_get_afs_token = 0;\n \tif (options->gss_authentication == -1)\n \t\toptions->gss_authentication = 0;\n \tif (options->gss_cleanup_creds == -1)\n \t\toptions->gss_cleanup_creds = 1;\n+\tif (options->gss_enable_mitm == -1)\n+\t\toptions->gss_enable_mitm = 0;\n \tif (options->password_authentication == -1)\n \t\toptions->password_authentication = 1;\n \tif (options->kbd_interactive_authentication == -1)\n \t\toptions->kbd_interactive_authentication = 0;\n \tif (options->challenge_response_authentication == -1)\n \t\toptions->challenge_response_authentication = 1;\n \tif (options->permit_empty_passwd == -1)\n \t\toptions->permit_empty_passwd = 0;\n@@ -335,17 +338,17 @@ typedef enum {\n \tsPermitUserEnvironment, sUseLogin, sAllowTcpForwarding, sCompression,\n \tsRekeyLimit, sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,\n \tsIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile,\n \tsGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem,\n \tsMaxStartups, sMaxAuthTries, sMaxSessions,\n \tsBanner, sUseDNS, sHostbasedAuthentication,\n \tsHostbasedUsesNameFromPacketOnly, sClientAliveInterval,\n \tsClientAliveCountMax, sAuthorizedKeysFile,\n-\tsGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel,\n+\tsGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel, sGssEnableMITM,\n \tsMatch, sPermitOpen, sForceCommand, sChrootDirectory,\n \tsUsePrivilegeSeparation, sAllowAgentForwarding,\n \tsHostCertificate,\n \tsRevokedKeys, sTrustedUserCAKeys, sAuthorizedPrincipalsFile,\n \tsKexAlgorithms, sIPQoS, sVersionAddendum,\n \tsAuthorizedKeysCommand, sAuthorizedKeysCommandUser,\n \tsAuthenticationMethods, sHostKeyAgent,\n \tsDeprecated, sUnsupported\n@@ -402,19 +405,21 @@ static struct {\n \t{ \"kerberosticketcleanup\", sUnsupported, SSHCFG_GLOBAL },\n \t{ \"kerberosgetafstoken\", sUnsupported, SSHCFG_GLOBAL },\n #endif\n \t{ \"kerberostgtpassing\", sUnsupported, SSHCFG_GLOBAL },\n \t{ \"afstokenpassing\", sUnsupported, SSHCFG_GLOBAL },\n #ifdef GSSAPI\n \t{ \"gssapiauthentication\", sGssAuthentication, SSHCFG_ALL },\n \t{ \"gssapicleanupcredentials\", sGssCleanupCreds, SSHCFG_GLOBAL },\n+\t{ \"gssapienablemitmattack\", sGssEnableMITM },\n #else\n \t{ \"gssapiauthentication\", sUnsupported, SSHCFG_ALL },\n \t{ \"gssapicleanupcredentials\", sUnsupported, SSHCFG_GLOBAL },\n+\t{ \"gssapienablemitmattack\", sUnsupported },\n #endif\n \t{ \"passwordauthentication\", sPasswordAuthentication, SSHCFG_ALL },\n \t{ \"kbdinteractiveauthentication\", sKbdInteractiveAuthentication, SSHCFG_ALL },\n \t{ \"challengeresponseauthentication\", sChallengeResponseAuthentication, SSHCFG_GLOBAL },\n \t{ \"skeyauthentication\", sChallengeResponseAuthentication, SSHCFG_GLOBAL }, /* alias */\n \t{ \"checkmail\", sDeprecated, SSHCFG_GLOBAL },\n \t{ \"listenaddress\", sListenAddress, SSHCFG_GLOBAL },\n \t{ \"addressfamily\", sAddressFamily, SSHCFG_GLOBAL },\n@@ -1085,16 +1090,20 @@ process_server_config_line(ServerOptions\n \tcase sGssAuthentication:\n \t\tintptr = &options->gss_authentication;\n \t\tgoto parse_flag;\n \n \tcase sGssCleanupCreds:\n \t\tintptr = &options->gss_cleanup_creds;\n \t\tgoto parse_flag;\n \n+\tcase sGssEnableMITM:\n+\t\tintptr = &options->gss_enable_mitm;\n+\t\tgoto parse_flag;\n+\n \tcase sPasswordAuthentication:\n \t\tintptr = &options->password_authentication;\n \t\tgoto parse_flag;\n \n \tcase sKbdInteractiveAuthentication:\n \t\tintptr = &options->kbd_interactive_authentication;\n \t\tgoto parse_flag;\n \ndiff --git a/openssh-6.6p1/servconf.h b/openssh-6.6p1/servconf.h\n--- a/openssh-6.6p1/servconf.h\n+++ b/openssh-6.6p1/servconf.h\n@@ -108,16 +108,17 @@ typedef struct {\n \t\t\t\t\t\t * such as SecurID or\n \t\t\t\t\t\t * /etc/passwd */\n \tint kerberos_ticket_cleanup;\t/* If true, destroy ticket\n \t\t\t\t\t\t * file on logout. */\n \tint kerberos_get_afs_token;\t\t/* If true, try to get AFS token if\n \t\t\t\t\t\t * authenticated with Kerberos. */\n \tint gss_authentication;\t/* If true, permit GSSAPI authentication */\n \tint gss_cleanup_creds;\t/* If true, destroy cred cache on logout */\n+\tint\t gss_enable_mitm;\t/* If true, enable old style GSSAPI */\n \tint password_authentication;\t/* If true, permit password\n \t\t\t\t\t\t * authentication. */\n \tint kbd_interactive_authentication;\t/* If true, permit */\n \tint challenge_response_authentication;\n \tint permit_empty_passwd;\t/* If false, do not permit empty\n \t\t\t\t\t * passwords. */\n \tint permit_user_env;\t/* If true, read ~/.ssh/environment */\n \tint use_login;\t/* If true, login(1) is used */\ndiff --git a/openssh-6.6p1/ssh_config b/openssh-6.6p1/ssh_config\n--- a/openssh-6.6p1/ssh_config\n+++ b/openssh-6.6p1/ssh_config\n@@ -51,9 +51,16 @@ ForwardX11Trusted yes\n # Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc\n # MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160\n # EscapeChar ~\n # Tunnel no\n # TunnelDevice any:any\n # PermitLocalCommand no\n # VisualHostKey no\n # ProxyCommand ssh -q -W %h:%p gateway.example.com\n+\n+# Set this to 'yes' to enable support for the deprecated 'gssapi' authentication\n+# mechanism to OpenSSH 3.8p1. The newer 'gssapi-with-mic' mechanism is included\n+# in this release. The use of 'gssapi' is deprecated due to the presence of \n+# potential man-in-the-middle attacks, which 'gssapi-with-mic' is not susceptible to.\n+# GSSAPIEnableMITMAttack no\n+\n # RekeyLimit 1G 1h\ndiff --git a/openssh-6.6p1/sshconnect2.c b/openssh-6.6p1/sshconnect2.c\n--- a/openssh-6.6p1/sshconnect2.c\n+++ b/openssh-6.6p1/sshconnect2.c\n@@ -318,16 +318,21 @@ static char *authmethods_get(void);\n \n Authmethod authmethods[] = {\n #ifdef GSSAPI\n \t{\"gssapi-with-mic\",\n \t\tuserauth_gssapi,\n \t\tNULL,\n \t\t&options.gss_authentication,\n \t\tNULL},\n+\t{\"gssapi\",\n+\t\tuserauth_gssapi,\n+\t\tNULL,\n+\t\t&options.gss_enable_mitm,\n+\t\tNULL},\n #endif\n \t{\"hostbased\",\n \t\tuserauth_hostbased,\n \t\tNULL,\n \t\t&options.hostbased_authentication,\n \t\tNULL},\n \t{\"publickey\",\n \t\tuserauth_pubkey,\n@@ -685,17 +690,19 @@ process_gssapi_token(void *ctxt, gss_buf\n \n \t\tpacket_put_string(send_tok.value, send_tok.length);\n \t\tpacket_send();\n \t\tgss_release_buffer(&ms, &send_tok);\n \t}\n \n \tif (status == GSS_S_COMPLETE) {\n \t\t/* send either complete or MIC, depending on mechanism */\n-\t\tif (!(flags & GSS_C_INTEG_FLAG)) {\n+\t\t\n+\t\tif (strcmp(authctxt->method->name,\"gssapi\") == 0 ||\n+\t\t (!(flags & GSS_C_INTEG_FLAG))) {\n \t\t\tpacket_start(SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE);\n \t\t\tpacket_send();\n \t\t} else {\n \t\t\tssh_gssapi_buildmic(&b, authctxt->server_user,\n \t\t\t authctxt->service, \"gssapi-with-mic\");\n \n \t\t\tgssbuf.value = buffer_ptr(&b);\n \t\t\tgssbuf.length = buffer_len(&b);\ndiff --git a/openssh-6.6p1/sshd_config b/openssh-6.6p1/sshd_config\n--- a/openssh-6.6p1/sshd_config\n+++ b/openssh-6.6p1/sshd_config\n@@ -80,16 +80,23 @@ PasswordAuthentication no\n #KerberosOrLocalPasswd yes\n #KerberosTicketCleanup yes\n #KerberosGetAFSToken no\n \n # GSSAPI options\n #GSSAPIAuthentication no\n #GSSAPICleanupCredentials yes\n \n+# Set this to 'yes' to enable support for the deprecated 'gssapi' authentication\n+# mechanism to OpenSSH 3.8p1. The newer 'gssapi-with-mic' mechanism is included\n+# in this release. The use of 'gssapi' is deprecated due to the presence of \n+# potential man-in-the-middle attacks, which 'gssapi-with-mic' is not susceptible to.\n+#GSSAPIEnableMITMAttack no\n+ \n+\n # Set this to 'yes' to enable PAM authentication, account processing,\n # and session processing. If this is enabled, PAM authentication will\n # be allowed through the ChallengeResponseAuthentication and\n # PasswordAuthentication. Depending on your PAM configuration,\n # PAM authentication via ChallengeResponseAuthentication may bypass\n # the setting of \"PermitRootLogin without-password\".\n # If you just want the PAM account and session checks to run without\n # PAM authentication, then enable this but set PasswordAuthentication"
}
] |
{
"id": "openssh-askpass-gnome-5136-openssh-6.6p1-gssapimitm.patch",
"cve_id": "CVE-2015-8325",
"package": "openssh-askpass-gnome",
"tier": "adapted",
"has_source_context": false,
"context_tokens_est": null,
"context_files": null,
"license": "BSD-2-Clause",
"upstream_enriched": null,
"upstream_commit": null,
"upstream_repo": null
}
|
CVE Backport Dataset v4
Source-context-aware security patch backporting dataset for SUSE/openSUSE, with per-example license information.
Used to train cve-backport-qwen32b-phase3.
Files
| File | Examples | Description |
|---|---|---|
data/train-chatml.jsonl |
1,883 | Training split in ChatML format |
data/eval-chatml.jsonl |
148 | Evaluation split in ChatML format |
What this dataset contains
Each example is a real CVE backporting task: an upstream security patch paired with its SUSE-adapted backport. 42% of examples also include relevant source code context from the target package version.
The model input (user message) contains:
- CVE identifier and description (from NVD)
- Target package name-version (e.g.
libxml2-2.9.1) - Files to modify (auto-detected from patch)
- Target source code (function-level context from the older version, when available)
- Upstream fix (unified diff)
The model output (assistant message) is the adapted SUSE backport patch in Index: quilt format.
Example structure
{
"messages": [
{"role": "system", "content": "You are a security patch backporting assistant..."},
{"role": "user", "content": "## CVE: CVE-2022-29824\n...upstream patch...\nGenerate a backported patch..."},
{"role": "assistant", "content": "Index: libxml2-2.9.1/buf.c\n===\n--- ..."}
],
"metadata": {
"id": "libxml2-1234-fix.patch",
"cve_id": "CVE-2022-29824",
"package": "libxml2",
"tier": "adapted",
"has_source_context": true,
"context_tokens_est": 1200,
"context_files": 2,
"license": "MIT"
}
}
Coverage
- 90 packages across 200+ CVEs
- Top packages: openssl (179), krb5 (127), krb5-mini (124), libxml2 (116), systemd (96)
- 42% with source context from upstream tarballs
Source and licensing
Derived from publicly available patches in the openSUSE Open Build Service. Each example's metadata.license field indicates the license of the source package. CVE descriptions are from the National Vulnerability Database (public domain).
License distribution
| License family | Count | Percentage |
|---|---|---|
| LGPL | 507 | 25.0% |
| MIT | 495 | 24.4% |
| GPL-3.x | 189 | 9.3% |
| BSD | 178 | 8.8% |
| GPL-2.x | 163 | 8.0% |
| MPL | 79 | 3.9% |
| Apache | 32 | 1.6% |
| Other (OpenSSL, ImageMagick, Zlib, etc.) | 388 | 19.1% |
Intended use
Training models to assist with security patch backporting — adapting upstream CVE fixes for older SUSE/openSUSE package versions.
References
- cve-backport-tool — CLI inference tool
- cve-backport-qwen32b-phase3 — trained model
- openSUSE Open Build Service
- Downloads last month
- 7