-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
copy_string error #37
Comments
Hi Haili, thanks for your suggestion. I really appreciate this. But this is already fixed now with I would however suggest you not using your proposed fix as this is insecure (have a read here), and actually fails in this case. The problem here is, that I forgot to replace the EOL character in the reading funtion, i.e. This means that the copied string won't be null-terminated, which might cause other problems. The copy_string function already did as you suggest, but adds a test whether the string is null-terminated after copying. As we were copying 4 ( void copy_string(char *dst, size_t size, const char *src){
strncpy(dst, src, size);
if (dst[size-1] != '\0'){
printf("cannot copy, string too long:\n%s\n", src);
exit(1);
}
return;
} The fix is to include this line here in
This even makes it safe to use a file with Windows EOL. Cheers, David |
Thanks David, |
For a Landsat scene (LC81210622020202LGN00), force-l2ps exits with error "cannot copy, string too long.". This happens at line 699 of src/lower-level/gas-ll.c:
copy_string(source, NPOW_02, tokenptr)
because apparently
tokenptr
contains a too long string, printing it gives "MYD". This happens when reading a dailyWVP_***.txt
file where "MYD" is in the last column. Perhaps there is no end-of-string character fortokenptr
? Anyways, replacing line 699 with:strncpy(source, tokenptr, NPOW_02)
makes the preprocessing succeed.
The text was updated successfully, but these errors were encountered: