An open API service indexing awesome lists of open source software.

https://github.com/katahiromz/win_popen_bug

Windows _popen bug
https://github.com/katahiromz/win_popen_bug

bug pipeline win32 win32api windows windows-10

Last synced: 7 months ago
JSON representation

Windows _popen bug

Awesome Lists containing this project

README

          

# Windows _popen bug found by @katahiromz

The following code works:

```c
fp = _popen("cmdline.exe \"--test=TE ST\"", "rb"); /* SUCCESSFUL */
if (fp)
{
while (fgets(buf, 256, fp))
{
fputs(buf, stdout);
}
_pclose(fp);
}
else
{
fprintf(stderr, "ERROR: Cannot execute 'cmdline.exe'\n");
return -1;
}
```

And then, the next code also works:

```c
fp = _popen("\"cm dline.exe\" --test=TEST", "rb"); /* SUCCESSFUL */
if (fp)
{
while (fgets(buf, 256, fp))
{
fputs(buf, stdout);
}
_pclose(fp);
}
else
{
fprintf(stderr, "ERROR: Cannot execute 'cm dline.exe'\n");
return -2;
}
```

But, the following code won't work:

```c
fp = _popen("\"cm dline.exe\" \"--test=TE ST\"", "rb"); /* BUG: this is failed */
if (fp)
{
while (fgets(buf, 256, fp))
{
fputs(buf, stdout);
}
_pclose(fp);
}
else
{
fprintf(stderr, "ERROR: Cannot execute 'cm dline.exe'\n");
return -3;
}
```

![The screenshot](win_popen_bug.png)