Replace inappropriate usage of strncpy by strlcpy

This commit is contained in:
Philippe Saint-Pierre 2011-11-27 11:10:39 -05:00
parent 3927bd3c0d
commit aec33db178
9 changed files with 11 additions and 11 deletions

View File

@ -98,7 +98,7 @@ EXRTranslator::DerivedIdentify(BPositionIO *stream,
outInfo->quality = EXR_IN_QUALITY;
outInfo->capability = EXR_IN_CAPABILITY;
strcpy(outInfo->MIME, "image/exr");
strncpy(outInfo->name, B_TRANSLATE("EXR image"),
strlcpy(outInfo->name, B_TRANSLATE("EXR image"),
sizeof(outInfo->name));
}
} catch (const std::exception &e) {

View File

@ -170,14 +170,14 @@ Identify(BPositionIO *inSource, const translation_format *inFormat,
outInfo->type = GIF_TYPE;
outInfo->quality = 0.8;
outInfo->capability = 0.8;
strncpy(outInfo->name, B_TRANSLATE("GIF image"), sizeof(outInfo->name));
strlcpy(outInfo->name, B_TRANSLATE("GIF image"), sizeof(outInfo->name));
strcpy(outInfo->MIME, "image/gif");
}
else {
outInfo->type = B_TRANSLATOR_BITMAP;
outInfo->quality = 0.3;
outInfo->capability = 0.3;
strncpy(outInfo->name, B_TRANSLATE("Be Bitmap Format (GIFTranslator)"),
strlcpy(outInfo->name, B_TRANSLATE("Be Bitmap Format (GIFTranslator)"),
sizeof(outInfo->name));
strcpy(outInfo->MIME, "image/x-be-bitmap");
}

View File

@ -238,7 +238,7 @@ identify_png_header(BPositionIO *inSource, translator_info *outInfo)
outInfo->quality = PNG_IN_QUALITY;
outInfo->capability = PNG_IN_CAPABILITY;
strcpy(outInfo->MIME, "image/png");
strncpy(outInfo->name, B_TRANSLATE("PNG image"),
strlcpy(outInfo->name, B_TRANSLATE("PNG image"),
sizeof(outInfo->name));
}

View File

@ -280,14 +280,14 @@ Identify( /* required */
outInfo->type = PPM_TYPE;
outInfo->quality = 0.3; /* no alpha, etc */
outInfo->capability = 0.8; /* we're pretty good at PPM reading, though */
strncpy(outInfo->name, B_TRANSLATE("PPM image"), sizeof(outInfo->name));
strlcpy(outInfo->name, B_TRANSLATE("PPM image"), sizeof(outInfo->name));
strcpy(outInfo->MIME, "image/x-portable-pixmap");
}
else {
outInfo->type = B_TRANSLATOR_BITMAP;
outInfo->quality = 0.4; /* B_TRANSLATOR_BITMAP can do alpha, at least */
outInfo->capability = 0.8; /* and we might not know many variations thereof */
strncpy(outInfo->name, B_TRANSLATE("Be Bitmap Format (PPMTranslator)"),
strlcpy(outInfo->name, B_TRANSLATE("Be Bitmap Format (PPMTranslator)"),
sizeof(outInfo->name));
strcpy(outInfo->MIME, "image/x-be-bitmap"); /* this is the MIME type of B_TRANSLATOR_BITMAP */
}

View File

@ -135,7 +135,7 @@ RTFTranslator::Identify(BPositionIO *stream,
info->group = B_TRANSLATOR_TEXT;
info->quality = RTF_IN_QUALITY;
info->capability = RTF_IN_CAPABILITY;
strncpy(info->name, B_TRANSLATE("RichTextFormat file"),
strlcpy(info->name, B_TRANSLATE("RichTextFormat file"),
sizeof(info->name));
strcpy(info->MIME, "text/rtf");

View File

@ -203,7 +203,7 @@ identify_sgi_header(BPositionIO *inSource, translator_info *outInfo, uint32 outT
outInfo->quality = SGI_IN_QUALITY;
outInfo->capability = SGI_IN_CAPABILITY;
strcpy(outInfo->MIME, "image/sgi");
strncpy(outInfo->name, B_TRANSLATE("SGI image"),
strlcpy(outInfo->name, B_TRANSLATE("SGI image"),
sizeof(outInfo->name));
}
} else {

View File

@ -305,7 +305,7 @@ BaseTranslator::identify_bits_header(BPositionIO *inSource,
outInfo->group = B_TRANSLATOR_BITMAP;
outInfo->quality = 0.2;
outInfo->capability = 0.2;
strncpy(outInfo->name, B_TRANSLATE("Be Bitmap Format"),
strlcpy(outInfo->name, B_TRANSLATE("Be Bitmap Format"),
sizeof(outInfo->name));
strcpy(outInfo->MIME, "image/x-be-bitmap");

View File

@ -860,7 +860,7 @@ identify_stxt_header(const TranslatorStyledTextStreamHeader &header,
outInfo->group = B_TRANSLATOR_TEXT;
outInfo->quality = STXT_IN_QUALITY;
outInfo->capability = STXT_IN_CAPABILITY;
strncpy(outInfo->name, B_TRANSLATE("Be styled text file"),
strlcpy(outInfo->name, B_TRANSLATE("Be styled text file"),
sizeof(outInfo->name));
strcpy(outInfo->MIME, "text/x-vnd.Be-stxt");

View File

@ -134,7 +134,7 @@ identify_wbi_header(BPositionIO* inSource, translator_info* outInfo,
outInfo->quality = WBI_IN_QUALITY;
outInfo->capability = WBI_IN_CAPABILITY;
strcpy(outInfo->MIME, "image/x-wonderbrush");
strncpy(outInfo->name, B_TRANSLATE("WonderBrush image"),
strlcpy(outInfo->name, B_TRANSLATE("WonderBrush image"),
sizeof(outInfo->name));
}
} else {