Changes in trunk/src/sh_utils.c [20:29]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_utils.c
r20 r29 189 189 } 190 190 191 int sh_util_hidesetup(c har * c)191 int sh_util_hidesetup(const char * c) 192 192 { 193 193 int i; … … 205 205 SL_ENTER(_("sh_util_strdup")); 206 206 207 if (str != NULL)208 { 209 210 211 212 } 207 SH_VALIDATE_NE(str, NULL); 208 209 len = sl_strlen(str); 210 p = SH_ALLOC (len + 1); 211 (void) sl_strlcpy (p, str, len+1); 212 213 213 SL_RETURN( p, _("sh_util_strdup")); 214 214 } … … 224 224 ret = *str; 225 225 226 if (ret == NULL) { 227 SL_RETURN(ret, _("sh_util_strsep")); 228 } 226 SH_VALIDATE_NE(ret, NULL); 229 227 230 228 for (c = *str; *c != '\0'; c++) { … … 646 644 static int sigtype = TYPE_HMAC; 647 645 648 int sh_util_sigtype (c har * c)646 int sh_util_sigtype (const char * c) 649 647 { 650 648 SL_ENTER(_("sh_util_sigtype")); … … 957 955 char * key; 958 956 char * path; 959 char * outpath ;957 char * outpath = NULL; 960 958 unsigned char * image = NULL; 961 959 long s = 0; … … 963 961 long ii, k = 0; 964 962 UINT32 * h1; 965 char * new ;963 char * new = NULL; 966 964 967 965 if (0 != sl_is_suid()) … … 999 997 fprintf(stderr, 1000 998 _("ERROR: no path to executable given\n Argument must be 'key@path'\n")); 999 free(new); 1001 1000 _exit (EXIT_FAILURE); 1002 1001 /*@notreached@*/ … … 1005 1004 else 1006 1005 path = &new[j]; 1006 1007 len = strlen(path) + 1 + 4; 1007 1008 /*@-usedef@*/ 1008 if (NULL == (outpath = malloc( strlen(path) + 1 + 4)))1009 if (NULL == (outpath = malloc(len))) 1009 1010 goto bail_mem; 1010 1011 /*@-usedef@*/ 1011 /*@-bufferoverflowhigh@*/ 1012 sprintf (outpath, _("%s.out"), path); /* known to fit */ 1013 /*@+bufferoverflowhigh@*/ 1012 sl_snprintf (outpath, len, _("%s.out"), path); 1014 1013 1015 1014 fp = sl_open_read(path, SL_NOPRIV); … … 1018 1017 fprintf(stderr, 1019 1018 _("ERROR: cannot open %s for read (errnum = %ld)\n"), path, fp); 1019 free(new); free (outpath); 1020 1020 _exit (EXIT_FAILURE); 1021 1021 /*@notreached@*/ … … 1028 1028 fprintf(stderr, 1029 1029 _("ERROR: cannot open %s (errnum = %ld)\n"), outpath, fout); 1030 free(new); free (outpath); 1030 1031 _exit (EXIT_FAILURE); 1031 1032 /*@notreached@*/ … … 1068 1069 (void) sl_close (fout); 1069 1070 printf(_("new file %s written\n"), outpath); 1071 free(new); free (outpath); free(image); 1070 1072 _exit (EXIT_SUCCESS); 1071 1073 /*@notreached@*/ … … 1076 1078 fprintf(stderr, 1077 1079 _("ERROR: old key not found\n")); 1080 free(new); free (outpath); free(image); 1078 1081 _exit (EXIT_FAILURE); 1079 1082 /*@notreached@*/ … … 1084 1087 fprintf(stderr, 1085 1088 _("ERROR: out of memory\n")); 1089 if (new) free(new); 1090 if (outpath) free (outpath); 1091 if (image) free (image); 1086 1092 _exit (EXIT_FAILURE); 1087 1093 /*@notreached@*/ … … 1329 1335 static unsigned char sh_obscure_index[256]; 1330 1336 1331 int sh_util_obscure_ok (c har * str)1337 int sh_util_obscure_ok (const char * str) 1332 1338 { 1333 1339 unsigned long i; 1334 char * endptr = str;1335 1336 SL_ENTER(_("sh_util_obscure_ ex"));1340 char * endptr = NULL; 1341 1342 SL_ENTER(_("sh_util_obscure_ok")); 1337 1343 1338 1344 if (0 == sl_strncmp("all", str, 3)) … … 1342 1348 sh_obscure_index[i] = (unsigned char)1; 1343 1349 } 1344 SL_RETURN(0, _("sh_util_obscure_ ex"));1350 SL_RETURN(0, _("sh_util_obscure_ok")); 1345 1351 } 1346 1352 … … 1349 1355 sh_obscure_index[i] = (unsigned char)0; 1350 1356 } 1357 1358 i = strtoul (str, &endptr, 0); 1359 if (i > 255) 1360 { 1361 SL_RETURN(-1, _("sh_util_obscure_ok")); 1362 } 1363 sh_obscure_index[i] = (unsigned char)1; 1364 if (*endptr == ',') 1365 ++endptr; 1351 1366 1352 1367 while (*endptr != '\0') … … 1355 1370 if (i > 255) 1356 1371 { 1357 SL_RETURN(-1, _("sh_util_obscure_ ex"));1372 SL_RETURN(-1, _("sh_util_obscure_ok")); 1358 1373 } 1359 1374 sh_obscure_index[i] = (unsigned char)1; … … 1361 1376 ++endptr; 1362 1377 } 1363 SL_RETURN(0, _("sh_util_obscure_ ex"));1378 SL_RETURN(0, _("sh_util_obscure_ok")); 1364 1379 } 1365 1380 1366 1381 int sh_util_obscurename (ShErrLevel level, char * name_orig, int flag) 1367 1382 { 1368 char * name =name_orig;1383 unsigned char * name = (unsigned char *) name_orig; 1369 1384 char * safe; 1370 1385 unsigned int i; … … 1378 1393 while (*name != '\0') 1379 1394 { 1380 if ( (*name) == '"' || (*name) == '\t' ||1395 if ( (*name) > 0x7F || (*name) == '"' || (*name) == '\t' || 1381 1396 (*name) == '\b' || (*name) == '\f' || 1382 1397 (*name) == '\n' || (*name) == '\r' || … … 1562 1577 } else if (!isgraph ((int) *p)) { /* not printable */ 1563 1578 /*@-bufferoverflowhigh -formatconst@*/ 1579 /* flawfinder: ignore */ 1564 1580 sprintf(oct, format, '\\', /* known to fit */ 1565 1581 (unsigned char) *p);
Note:
See TracChangeset
for help on using the changeset viewer.