]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
mprintf: check fputc error rather than matching returned character
authorPatrick Monnerat <patrick@monnerat.net>
Sun, 14 Apr 2024 12:20:28 +0000 (14:20 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 15 Apr 2024 06:38:14 +0000 (08:38 +0200)
OS/400 ascii fputc wrapper deviates from the posix standard by the
fact that it returns the ebcdic encoding of the original ascii
character. Testing for a matching value for success will then always
fail.

This commit replaces the chariacter comparison by an explicit error
return check.

Follow-up to ef2cf58
Closes #13367

lib/mprintf.c

index 4c60d13305b2890bbc19d9cb93be924ee1c6bee8..3ce3a7788c21e3e5c77b8ad246701c851506f38a 100644 (file)
@@ -1160,9 +1160,7 @@ static int fputc_wrapper(unsigned char outc, void *f)
   int out = outc;
   FILE *s = f;
   int rc = fputc(out, s);
-  if(rc == out)
-    return 0;
-  return 1;
+  return rc == EOF;
 }
 
 int curl_mprintf(const char *format, ...)