Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Dec 2005 23:42:27 +0100 (CET)
From:      Florian Westphal <westphal@foo.fh-furtwangen.de>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/90580: wordexp(3) fails to check for EINTR	
Message-ID:  <20051217224227.B65E4242@abraxis.ask.fh-furtwangen.de>
Resent-Message-ID: <200512172240.jBHMe1hj085266@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         90580
>Category:       bin
>Synopsis:       wordexp(3) fails to check for EINTR
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 17 22:40:01 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Florian Westphal
>Release:        FreeBSD 5.4-RELEASE-p6 i386
>Organization:
>Environment:
System: FreeBSD abraxis.ask.fh-furtwangen.de 5.4-RELEASE-p6 FreeBSD 5.4-RELEASE-p6 #12: Wed Aug 17 09:26:21 CEST 2005 root@abraxis.ask.fh-furtwangen.de:/usr/obj/usr/src/sys/ABRAXIS i386

	AMD k6/233 mhz, 32meg ram
>Description:
	wordexp() fails if a syscall fails; no check for errno == EINTR is performed.
	Applications that install signal handlers for SIGCHLD will be in a race with
	wordexp. The program below often fails on my box.
>How-To-Repeat:
/* This sample program MAY work or not work, depending on timing */ 
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>	
#include <wordexp.h>

static void handler(int x) { (void)x; } 

int main(void)
{
	struct sigaction sa;
	const char * expand = "*";
	wordexp_t p;
	int ret;

        sa.sa_flags = 0;
        sigemptyset(&sa.sa_mask);
        sa.sa_handler = handler;
        if (sigaction(SIGCHLD,&sa, NULL) != 0)
		return 111;

	errno = 0;	
        ret = wordexp(expand, &p, WRDE_SHOWERR|WRDE_UNDEF);
        if (ret == 0) {
                unsigned int i;
                char **w = p.we_wordv;
                for (i=0; i<p.we_wordc; i++)
                        printf("got token: \"%s\"\n", w[i]);

                wordfree(&p);
        } else {
		printf("wordexp failed, ret %d, err %s\n:", ret, strerror(errno));
	}
	return 0;
}
>Fix:
	Have wordexp() check for errno == EINTR


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051217224227.B65E4242>