aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/lang/natThread.cc
AgeCommit message (Expand)AuthorFilesLines
2007-07-31configure.ac (INTERPRETER): New AM_CONDITIONAL.David Daney1-0/+7
2007-02-16Thread.java (Thread(ThreadGroup, Runnable, String)): Pass new parameter const...David Daney1-2/+2
2007-01-17natThread.cc (finish_): Add JVMTI ThreadEnd notification.Keith Seitz1-0/+11
2007-01-17natThread.cc (finalize_native): Remove cast.Tom Tromey1-2/+2
2007-01-09Merged gcj-eclipse branch to trunk.Tom Tromey1-28/+72
2006-08-21re PR libgcj/13212 (JNI/CNI AttachCurrentThread does not register thread with...Bryce McKinlay1-1/+5
2006-07-21natThread.cc (_Jv_ThreadGetData): New function.Keith Seitz1-0/+7
2006-05-29natThread.cc (countStackFrames): Do not throw UnsupportedOperationException.Thomas Fitzsimmons1-9/+13
2006-05-13sources.am, [...]: Rebuilt.Tom Tromey1-0/+3
2006-01-06natThread.cc (finish_): Don't clear 'group'.Tom Tromey1-3/+1
2005-09-27re PR libgcj/23367 (_Jv_FindMethodInCache is not thread-safe)Tom Tromey1-1/+4
2005-06-29re PR libgcj/22211 ([4.0 only] Thread.interrupt sometimes causes abort if thr...Tom Tromey1-3/+11
2005-01-14jni.h (_Jv_JNIEnv::bottom_locals): New field.Graydon Hoare1-0/+1
2005-01-13re PR libgcj/17784 (Thread.interrupt doesn't do security checks)Michael Koch1-0/+2
2004-09-11natThread.cc (finalize_native): Destroy join conditional variable and mutex i...Mohan Embar1-0/+6
2004-05-28gcj.texi (Object allocation): Remove _Jv_AllocBytes.Bryce McKinlay1-5/+2
2004-03-092004-03-09 Michael Koch <konqueror@gmx.de>Michael Koch1-9/+0
2003-10-21posix-threads.cc (_Jv_CondNotify,_Jv_CondNotifyAll): Rename _Jv_PthreadCheckM...Jerry Quinn1-0/+8
2002-04-10Makefile.in: Rebuilt.Tom Tromey1-1/+16
2001-08-26Makefile.am: New friends for java/lang/Thread.h.Bryce McKinlay1-15/+36
2001-05-21Implement invocation interface; don't create new thread for main.Per Bothner1-2/+60
2001-03-25exception.cc (java_eh_info): Make value type jthrowable.Richard Henderson1-10/+10
2000-12-30For boehm-gc:Bryce McKinlay1-6/+19
2000-06-21ThreadGroup.java (add(Thread)): Rename to addThread() to comply with classpat...Bryce McKinlay1-1/+1
2000-05-18Thread.java: Declare `data' as Object, not RawData.Bryce McKinlay1-2/+1
2000-04-02JVMPI changes...Anthony Green1-0/+73
2000-03-28Makefile.in: New #defines and friends for Thread.h.Bryce McKinlay1-132/+32
2000-03-07All files: Updated copyright information.Tom Tromey1-1/+1
2000-03-02java-interp.h: Don't include MethodInvocation.h.Tom Tromey1-5/+23
2000-02-15natThread.cc (dumpStack): Removed.Bryce McKinlay1-9/+0
2000-02-10natNativeThread.cc: New file.Tom Tromey1-2/+28
2000-02-10interpret.cc: Don't include fdlibm.h.Andrew Haley1-2/+5
2000-01-19* All files: Updated copyright to reflect Cygnus purchase.Tom Tromey1-1/+1
1999-12-24natObject.cc (notify): Throw message with IllegalMonitorStateException.Bryce McKinlay1-6/+10
1999-11-05* java/lang/natThread.cc (destroy): Removed incorrect comment.Tom Tromey1-2/+0
1999-11-05natThread.cc (stop): Removed argument name.Tom Tromey1-1/+1
1999-11-04quick-threads.h (_Jv_ThreadCancel): Removed.Tom Tromey1-6/+1
1999-09-10configure: Rebuilt.Tom Tromey1-1/+3
1999-08-19natThread.cc (class locker): New class.Tom Tromey1-7/+31
1999-08-18ThreadGroup.java: Fixed now-erroneous comment.Tom Tromey1-0/+2
1999-08-18natThread.cc (sleep): Turn 0 millis and 0 nanos into 1 nano.Tom Tromey1-0/+3
1999-04-07Initial revisionTom Tromey1-0/+295
id='n86' href='#n86'>86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
/* Test for processing of invalid gshadow entries.  [BZ #18724]
   Copyright (C) 2015 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, see
   <http://www.gnu.org/licenses/>.  */

#include <errno.h>
#include <gshadow.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static bool errors;

static void
check (struct sgrp e, const char *expected)
{
  char *buf;
  size_t buf_size;
  FILE *f = open_memstream (&buf, &buf_size);

  if (f == NULL)
    {
      printf ("open_memstream: %m\n");
      errors = true;
      return;
    }

  int ret = putsgent (&e, f);

  if (expected == NULL)
    {
      if (ret == -1)
	{
	  if (errno != EINVAL)
	    {
	      printf ("putsgent: unexpected error code: %m\n");
	      errors = true;
	    }
	}
      else
	{
	  printf ("putsgent: unexpected success (\"%s\")\n", e.sg_namp);
	  errors = true;
	}
    }
  else
    {
      /* Expect success.  */
      size_t expected_length = strlen (expected);
      if (ret == 0)
	{
	  long written = ftell (f);

	  if (written <= 0 || fflush (f) < 0)
	    {
	      printf ("stream error: %m\n");
	      errors = true;
	    }
	  else if (buf[written - 1] != '\n')
	    {
	      printf ("FAILED: \"%s\" without newline\n", expected);
	      errors = true;
	    }
	  else if (strncmp (buf, expected, written - 1) != 0
		   || written - 1 != expected_length)
	    {
	      printf ("FAILED: \"%s\" (%ld), expected \"%s\" (%zu)\n",
		      buf, written - 1, expected, expected_length);
	      errors = true;
	    }
	}
      else
	{
	  printf ("FAILED: putsgent (expected \"%s\"): %m\n", expected);
	  errors = true;
	}
    }

  fclose (f);
  free (buf);
}

static int
do_test (void)
{
  check ((struct sgrp) {
      .sg_namp = (char *) "root",
    },
    "root:::");
  check ((struct sgrp) {
      .sg_namp = (char *) "root",
      .sg_passwd = (char *) "password",
    },
    "root:password::");
  check ((struct sgrp) {
      .sg_namp = (char *) "root",
      .sg_passwd = (char *) "password",
      .sg_adm = (char *[]) {(char *) "adm1", (char *) "adm2", NULL},
      .sg_mem = (char *[]) {(char *) "mem1", (char *) "mem2", NULL},
    },
    "root:password:adm1,adm2:mem1,mem2");

  /* Bad values.  */
  {
    static const char *const bad_strings[] = {
      ":",
      "\n",
      ":bad",
      "\nbad",
      "b:ad",
      "b\nad",
      "bad:",
      "bad\n",
      "b:a\nd",
      ",",
      "\n,",
      ":,",
      ",bad",
      "b,ad",
      "bad,",
      NULL
    };
    for (const char *const *bad = bad_strings; *bad != NULL; ++bad)
      {
	char *members[]
	  = {(char *) "first", (char *) *bad, (char *) "last", NULL};
	if (strpbrk (*bad, ":\n") != NULL)
	  {
	    check ((struct sgrp) {
		.sg_namp = (char *) *bad,
	      }, NULL);
	    check ((struct sgrp) {
		.sg_namp = (char *) "root",
		.sg_passwd = (char *) *bad,
	      }, NULL);
	  }
	check ((struct sgrp) {
	    .sg_namp = (char *) "root",
	    .sg_passwd = (char *) "password",
	    .sg_adm = members
	  }, NULL);
	check ((struct sgrp) {
	    .sg_namp = (char *) "root",
	    .sg_passwd = (char *) "password",
	    .sg_mem = members
	  }, NULL);
      }
  }

  return errors;
}

#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"