Created
May 13, 2014 00:06
-
-
Save gdamore/33cf6c330f3248314fe3 to your computer and use it in GitHub Desktop.
mixed n$ crap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/usr/src/cmd/printf/printf.c b/usr/src/cmd/printf/printf.c | |
index fe1bb1b..bf07982 100644 | |
--- a/usr/src/cmd/printf/printf.c | |
+++ b/usr/src/cmd/printf/printf.c | |
@@ -224,12 +224,19 @@ doformat(char *fmt, int *rval) | |
l = strspn(fmt, digits); | |
if ((l > 0) && (fmt[l] == '$')) { | |
int idx = atoi(fmt); | |
+ if (fargv == NULL) { | |
+ warnx1(_("incomplete use of n$"), NULL, NULL); | |
+ return (NULL); | |
+ } | |
if (idx <= myargc) { | |
gargv = &myargv[idx - 1]; | |
} else { | |
gargv = &myargv[myargc]; | |
} | |
fmt += l + 1; | |
+ } else if (fargv != NULL) { | |
+ warnx1(_("incomplete use of n$"), NULL, NULL); | |
+ return (NULL); | |
} | |
if (getint(&fieldwidth)) | |
@@ -262,12 +269,20 @@ doformat(char *fmt, int *rval) | |
l = strspn(fmt, digits); | |
if ((l > 0) && (fmt[l] == '$')) { | |
int idx = atoi(fmt); | |
+ if (fargv == NULL) { | |
+ warnx1(_("incomplete use of n$"), | |
+ NULL, NULL); | |
+ return (NULL); | |
+ } | |
if (idx <= myargc) { | |
gargv = &myargv[idx - 1]; | |
} else { | |
gargv = &myargv[myargc]; | |
} | |
fmt += l + 1; | |
+ } else if (fargv != NULL) { | |
+ warnx1(_("incomplete use of n$"), NULL, NULL); | |
+ return (NULL); | |
} | |
if (getint(&precision)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment