Skip to content

Instantly share code, notes, and snippets.

@jeandrek
Created March 4, 2018 05:31
Show Gist options
  • Save jeandrek/2b69f0592ec75700d09df5b5c81359ca to your computer and use it in GitHub Desktop.
Save jeandrek/2b69f0592ec75700d09df5b5c81359ca to your computer and use it in GitHub Desktop.
Windows patch for 4.4BSD uudecode
--- ../Downloads/uudecode.c 1994-04-03 06:16:37 +1200
+++ uudecode.c 2018-03-04 18:23:50 +1300
@@ -50,8 +50,8 @@
#include <sys/param.h>
#include <sys/stat.h>
-#include <pwd.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
char *filename;
@@ -85,7 +85,6 @@
decode()
{
extern int errno;
- struct passwd *pw;
register int n;
register char ch, *p;
int mode, n1;
@@ -103,32 +102,11 @@
/* handle ~user/file format */
if (buf[0] == '~') {
- if (!(p = index(buf, '/'))) {
- (void)fprintf(stderr, "uudecode: %s: illegal ~user.\n",
- filename);
- return(1);
- }
- *p++ = NULL;
- if (!(pw = getpwnam(buf + 1))) {
- (void)fprintf(stderr, "uudecode: %s: no user %s.\n",
- filename, buf);
- return(1);
- }
- n = strlen(pw->pw_dir);
- n1 = strlen(p);
- if (n + n1 + 2 > MAXPATHLEN) {
- (void)fprintf(stderr, "uudecode: %s: path too long.\n",
- filename);
- return(1);
- }
- bcopy(p, buf + n + 1, n1 + 1);
- bcopy(pw->pw_dir, buf, n);
- buf[n] = '/';
}
/* create output file, set mode */
if (!freopen(buf, "w", stdout) ||
- fchmod(fileno(stdout), mode&0666)) {
+ _chmod(buf, mode&0666)) {
(void)fprintf(stderr, "uudecode: %s: %s: %s\n", buf,
filename, strerror(errno));
return(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment